Hello Catalysters:

First of all, a thousand apologies if this is a FAQ (and if it is, please point me in the right direction). I have been programming in Perl for a while but I freely admit there's a lot I don't know, which is why I am here. I have completed the Catalyst tutorial, purchased the book (which I am in the process of reading/completing) and I have scrutinized all sorts of web pages trying to figure this out, but have so far been unsuccessful.

Here's the problem I'm trying to solve: I have a partially-written web application which I am trying to port to Catalyst. My app has DBI methods to access the DB and return results -- things like get_vendor_by_name() or get_option_list(). In Java, which is the language I use most often these days, I would think of them as DAO methods. Some of these methods are fairly trivial to replace in Catalyst; for example, get_vendor_by_name now becomes $c->resultset('Vendor')->search({name => $vendor_name})->all; However, some of these methods are more complicated/complex and the proper DBIC invocation to produce an equivalent result to my DBI method is more than I would want to try to remember or replace each time I need to perform that query. I don't mind re-writing the methods to use DBIC instead of DBI (in fact, I kind of look forward to it), but I would like to continue to have complex or semi-complex queries abstracted into their own methods which I can re-use easily. The problem is that I don't know where to put them or how to access them.

So, my question is: In a Catalyst context, where do I put these kinds of "helper" DB methods and how do I access them? (both from within a Catalyst app, as well as from the command-line like in a Cron job or whatever...) Some actual specific examples would be great. I'm sure there is a way, and I'm guessing it involves the model somehow (possibly by creating a new model class?) but I haven't been able to figure it out yet. I tried adding methods to the classes created by Catalyst/DBIC in the Schema/Result directory, but gradually it dawned on me that methods placed here are only dealing with a single entity of that type. To go back to Java-speak, it seems like the stuff in Schema/Result are DTO methods; what I'm trying to figure out is how/where to put the DAO methods.

Help!  :-)  Thanks.

jarom smith
tech go-to guy


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to