[CDBI] Scope of autoupdate/update?
Christopher H. Laco
claco at chrislaco.com
Tue Aug 2 20:36:12 BST 2005
First, a little background. While working on the AxKit taglib for
Handel, I made the decision that when updating multiple fields in the
xml, it would be best to turn off autoupdates until all of the updates
have been assembled and the parent tag was closed.
<cart:cart> <!-- turn off autoupdate -->
<cart:name>My Cart Name</cart:name>
<cart:description>My Cart Description</cart:description>
<cart:comments>Hey look at me!</cart:comments>
</cart:cart> <!-- call update() manually -->
This is in contrast to how the classes themselves work in normal perl:
my $cart = Handel::Cart->new;
$cart->name('My Cart Name'); # DB updated..
$cart->description('My Cart Description'); # DB updated..
$cart->comments('Hey look at me'); # DB updated..
Lately, I've had the urge to take that a step further. Turn off
autoupdates for the has_a items in the cart instance....this has led me
to a few questions for which I don't know the answer.
First, is autoupdate() scoped to the package namespace, or to the
package instance, or Does The Right Thing? If the package is set to
__PACKAGE__->autoupdate(1), that applies to all instances created from
that package in an apache mod_perl child process right?
So, when I call __PACKAGE__->new->autoupdate(1), are autoupdates turned
on for that blessed instance, or did I just flip the autoupdates bit for
every instance of that package in the mod_perl apacke child process
namespace for __PACKAGE__?
And the last question is of course, if I turn off an instances
autoupdate bit, is there any chance that that propogates to the child
objects returned by has_a relationships?
I think it should be possible to create a custom HAS_A relationship
class that automatically flips the autoupdate bit based on the parents
autoupdate bit, but that of course assumes that autoupdate is scoped
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3178 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20050802/78c8e7d8/smime.bin
More information about the ClassDBI