Re: [RDBO] Customising R:D:O:Loader generated methods
Adrian == Adrian Howard [EMAIL PROTECTED] writes: Adrian I've got a whole mess-o-tables that (by and large) Adrian Rose::DB::Object::Loader deals with splendidly. However, there are a Adrian few columns where I would like to do a little client-side stuff Adrian before I update a column in an object. See Triggers in Rose::DB::Object::Metadata::Column. At one point, I even knew how to wire that in to Loader, but I bet someone else will fill that in as an example. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Customising R:D:O:Loader generated methods
On 21 Feb 2007, at 13:51, Randal L. Schwartz wrote: Adrian == Adrian Howard [EMAIL PROTECTED] writes: Adrian I've got a whole mess-o-tables that (by and large) Adrian Rose::DB::Object::Loader deals with splendidly. However, there are a Adrian few columns where I would like to do a little client-side stuff Adrian before I update a column in an object. See Triggers in Rose::DB::Object::Metadata::Column. At one point, I even knew how to wire that in to Loader, but I bet someone else will fill that in as an example. As I understand it triggers happen after the object is updated in memory. I want to shim stuff in before this (so I can preserve the original value if I don't want the update to proceed) Happy to be educated if incorrect though :-) Cheers, Adrian - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Customising R:D:O:Loader generated methods
On 2/21/07, Adrian Howard [EMAIL PROTECTED] wrote: Rose::DB::Object::Loader-new( db = MyApp::DB-new, class_prefix = 'MyApp' )-make_classes( pre_init_hook = sub { my $meta = shift; $meta-column( 'some_column' )-alias( '_some_column' ) if $meta-table eq 'some_table'; } ); then off in MyApp::SomeTable I do: sub some_column { my $self = shift; # ...stuff I need to do before changing value goes here... return $self-_some_column( @_ ); } Reasonable? Is there a better way (for some definition of better)? That's reasonable. I've done similar things in generated and manually created classes. As I understand it triggers happen after the object is updated in memory. I want to shim stuff in before this (so I can preserve the original value if I don't want the update to proceed) You're right that the on_set trigger happens after the column value has been set. I could probably stand to add a few more trigger events (e.g., before_set) but I'm wary of trigger-itis gumming up the works. So I've just been waiting to see what kinds of events people actually need. It seems like you're registering one vote for before_set :) But in the meantime, the technique you're using instead is fine. -John - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Customising R:D:O:Loader generated methods
On 21 Feb 2007, at 14:40, John Siracusa wrote: [snip] That's reasonable. I've done similar things in generated and manually created classes. [snip] Super :) As I understand it triggers happen after the object is updated in memory. I want to shim stuff in before this (so I can preserve the original value if I don't want the update to proceed) You're right that the on_set trigger happens after the column value has been set. I could probably stand to add a few more trigger events (e.g., before_set) but I'm wary of trigger-itis gumming up the works. So I've just been waiting to see what kinds of events people actually need. It seems like you're registering one vote for before_set :) But in the meantime, the technique you're using instead is fine. ++ for before_set :-) Cheers, Adrian PS And thanks for R:D:O - it keeps exceeding my expectations. - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Customising R:D:O:Loader generated methods
On Feb 21, 2007, at 6:10 AM, Adrian Howard wrote: Reasonable? Is there a better way (for some definition of better)? personally, i use wrappers for all my rdb objects my 'page objects' can only write to 'data objects' the data objects handle loading / unloading rose objects as internal stashes, provide a layer for other objects to read the rose data, and handle the write / update logic in a tree structure, the modules are organized like this: /DataObject/ /Page/ /RoseDB/ it works out pretty well. if i ever needed to abandon rose ( that would never happen though ! ) , everything that hits rose is consolidated in the DataObject tree all the hooks , pre processing / whatever can also happen within update modules in DataObject its not a better solution, but it works :) // Jonathan Vanasco | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | SyndiClick.com | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | FindMeOn.com - The cure for Multiple Web Personality Disorder | Web Identity Management and 3D Social Networking | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | RoadSound.com - Tools For Bands, Stuff For Fans | Collaborative Online Management And Syndication Tools | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Customising R:D:O:Loader generated methods
On Wed, 21 Feb 2007 09:40:53 -0500 John Siracusa [EMAIL PROTECTED] wrote: JS You're right that the on_set trigger happens after the column value JS has been set. I could probably stand to add a few more trigger events JS (e.g., before_set) but I'm wary of trigger-itis gumming up the works. JS So I've just been waiting to see what kinds of events people actually JS need. It seems like you're registering one vote for before_set :) The name escapes me, but there was a CPAN module that worked like the Lisp defadvice function, which essentially creates an invisible wrapper around a Lisp function. That always struck me as a more elegant solution that adding triggers, but searching for advice didn't give any good results among 150+ hits. Ted - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object