Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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 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?


Matt R.

Replies are listed 'Best First'.
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.


      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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://531891]
Approved by Corion
Front-paged by planetscape
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2018-05-21 09:57 GMT
Find Nodes?
    Voting Booth?