Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Persistence for Class::MethodMaker?

by mattr (Curate)
on Feb 22, 2006 at 08:28 UTC ( #531891=perlquestion: print w/ replies, xml ) Need Help??
mattr has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

How do you implement Class::MethodMaker persistence, and can it be done fully through Class::DBI?

I need persistent OO storage for an app that can be in both CGI or a wxperl gui app, on unix or windows.. I want to use DBI but not be forced to use a server-based database i.e. use dbm or SQLite (though FAILs are shown for SQLite). I'm having trouble persisting Class::MethodMaker, and can't see if it will really work with Class::DBI which I have used. There is a past thread from someone with the same idea and a kludge. Failing that some other transparent mechanism (if possible using DBI.pm) would be needed, preferably not just serializing the whole object into a single bloblike field.

Also, I found you can't dump the entire object with Data::Dumper unless you vivify each field manually.. or is there a way?

Some issues seem to be class arrays/hashes, setting defaults, overridden methods, and using both Class::DBI and MethodMaker idioms. Class::DBI has its own ways of doing them.

Also I have looked at Class::Generate which is interesting but same question about how to automatically persist.

Currently I am thinking about giving up on Class::MethodMaker and am painfully trying for the first time to wedge Class::DBI into a dbm (mldbm) (lots of carping). But what I'd love is transparent storage of Class::MethodMaker through Class::DBI.. all the calories and you don't get fat, yup. Any ideas?

Sincerely,

Matt R.

Comment on Persistence for Class::MethodMaker?
Re: Persistence for Class::MethodMaker?
by demerphq (Chancellor) on Feb 23, 2006 at 11:00 UTC

    Try dumping the package hash using Data::Dump::Streamer. That should allow you to eval the package back into existance.

    ---
    $world=~s/war/peace/g

      Thanks. Um what do you mean?.. I'm dumb tonight. I haven't gotten anything much from deparsing.

      Well, I realize mixing Class::DBI and Class::MethodMaker are probably a bad idea. That is, it would be a great idea if it worked. Generally I'd like to know if anybody has an automated way to persist Class::MethodMaker classes in general.

      Of course with dbm you are only using the first field as a key anyway. It works now but I will try going to SQLite. Anyway I have gotten a bit used to Class::DBI though it seems slow, because it is pretty straightforward.

      I've been reading about Maypole and things like Class::Loader::Relationships which is kind of interesting.

      I wonder if using Maypole things in a wxperl app is a bad idea. :) It seems that might be useful in speeding object definitions up, after taking the initial hit.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://531891]
Approved by Corion
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-12-28 14:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (181 votes), past polls