On 12/4/05 8:58 PM, Michael Alan Dorman wrote: > Hmm. The method you outlined in your message of swapping DB handles > dynamically didn't seem all that arduous. Perhaps just the tiniest > bit of infrastructure could help. > > I guess I'm thinking along the lines of a hook for each operation > where you could install that would get called with a reference of the > object at hand and could inspect the object to its heart's content to > determine what database to run it against?
RDBO generally eschews hooks in favor of subclass-and-override. Hooks tend to be performance drains, especially in Perl where method call overhead is significant. "Check for any pre-foo hooks, do foo, check for any on-foo hooks, check for any post-foo hooks, and finally return." It all adds up. That said, I did add column triggers using hooks, but I did so in a way that keeps all hook checks out of the code path in the common (no hook) case. I could do something similar with save(), but there are already a bunch of implicit pre/post operations for inserting and updating related objects. Adding hooks on top of hooks tends to get very confusing for all involved. RDBO is designed to be subclassed. Overriding load() and save() is straightforward, and probably the most common subclassing task. I suggest customizing your common RDBO-derived base class and adding the hook you describe. It'll be reasonably efficient for you because you know exactly what you want to do. A general solution has to do more, and will therefore be slower (and probably more complex). Were I to create one, I'd use a subclass too. (Rose::DB::Object::Cached is meant as an example of this appraoch.) I'd probably create Rose::DB::Object::Partitioned, were I to have some bright idea about a very generic way to do it. You, OTOH, just need to know how to do specifically what you want to do. And you seem to, so do it! :) If you need any help in the implementation, just ask. But I think it'll be pretty smooth for you. -John ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object