From: Chris W. <ch...@cw...> - 2004-01-07 01:38:02
|
On Jan 6, 2004, at 2:55 PM, Vsevolod (Simon) Ilyushchenko wrote: >> Ugh, that blows. I'm going to introduce a initialize_custom() method >> to SPOPS.pm which you can override to do whatever you want. This is a >> very useful feature and I can't believe it's not there already. > > Cool - should be useful. This is in CVS now -- if you're interested LMK and I'll make a dist available. >> You still need to initialize your SPOPS classes before trying to use >> 'Job'. See the tarball above for my example. > > OH!!! You are doing this OUTSIDE of the classes! Thanks, got it! > > But... this violates encapsuliation... though I see how you have to go > outside of the box to define the circular relationships... Yeah... what you're doing is defining an object and inheriting all the persistent behavior. Even though the class with the persistent behavior isn't defined until you create it using SPOPS::Initialize. (Perl lets you do this.) The previous normal practice for SPOPS was to define a class with your custom behavior and bring it in using the 'code_class' configuration key. This is such an ugly hack I shouldn't even discuss it :-) > BTW, do I understand correctly that links_to objects are loaded in a > lazy manner, that is, they are not fetched until the method to access > them is explicitly invoked? Correct. I have a strong aversion to systems that load dependencies automatically because you wind up fetching a huge graph when you want a simple object. Chris -- Chris Winters Creating enterprise-capable snack systems since 1988 |