[Dbix-class] design thought

Todd Hepler thepler at watson.wustl.edu
Sat Jul 30 00:02:27 CEST 2005


Considering that the module name has already been chosen and it includes 
"DBI", this idea may be a bit out of scope.  Nonetheless, I'd like to 
throw it out there to see what people think.

One of my frustrations with cdbi is that it is limited to DBI and 
assumes that all the objects represent rows in a database.

Consider making a call to retrieve() or search() as a request for 
objects.  In the cdbi world then, DBI is responsible for fulfillment of 
that request, and cdbi responds with objects.

Now say that, for some classes, I'd like to have something other than 
DBI be responsible for fulfillment while having the resulting objects 
conform to the same general interface.  Maybe people would contribute 
plugins for different kinds of fulfillment engines.  For example:

@file = MyApp::File->search({dir => '/home/thepler/bin'});

And something knew that requests for the My::File class should use the 
::FileSystem (or whatever it might be called) fullfilment engine and it 
would return objects that represent each file in my bin directory.

Or maybe you have the class MyApp::WebPage that says it's primary key is 
'url', so you could do:

$wp = MyApp::WebPage->retrieve('http://lists.rawmode.org/');

And the ::LWP fulfillment engine would get the page and return an object 
that holds it's attributes.

One potentially powerful thing that could then be done is to define 
relationships between, say, a row in your database and a file on the 
filesystem, or a row and a web page, or a row and any other arbitrary 
thing that you care to write a fulfillment engine for.

Do you think dbix-class might be flexible enough for such a thing?  Or 
am I destined to roll my own?

Thanks,
Todd Hepler




More information about the Dbix-class mailing list