Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Help seperating business logic from controller (catalyst/dbic)

by uG (Scribe)
on Sep 09, 2008 at 13:22 UTC ( #710081=note: print w/replies, xml ) Need Help??


in reply to Re^3: Help seperating business logic from controller (catalyst/dbic)
in thread Help seperating business logic from controller (catalyst/dbic)

This is what I was getting at. Originally I had taken the rule part and did just what you had said, put it in DB::Nation and set it up to handle exceptions. My problem at that point was I wasn't quite sure how to call a method from a Schema file (or to put it in the same namespace). I'll admit i'm pretty lost, but I can't find a good example on how to do this :(
  • Comment on Re^4: Help seperating business logic from controller (catalyst/dbic)

Replies are listed 'Best First'.
Re^5: Help seperating business logic from controller (catalyst/dbic)
by perrin (Chancellor) on Sep 09, 2008 at 13:45 UTC
    I don't use DBIx::Class, so I can't help you with the mechanics of that. You could always create a separate action class that isn't part of your DBIx::Class stuff. You also don't have to use all the Catalyst window-dressing like $c->model() if it makes things more confusing for you rather than less.
Re^5: Help seperating business logic from controller (catalyst/dbic)
by stonecolddevin (Vicar) on Sep 09, 2008 at 17:51 UTC

    Yea, you can put your db/model methods in a ::Schema namespace, but it all comes down to what works best for you. I don't know that you'll hear one consistent method or another, so it's best to use what makes sense to *you*. If it happens to be so far off it's going to cause you trouble, you can certainly have someone in #catalyst do a code review for you and let you know.

    As long as it's reasonably sane, and most importantly, followable by others (and you!), there shouldn't be a problem.

    I have however, separated my model classes into ModelName::TableName for the table definitions and ModelName::TableName::ResultSet for the "most used methods" such as specific searches (getPosts(), getUser() etc.). You have to realize most, if not all, of that is documented in the DBIx::Class::* family. Catalyst has a few pointers, but what you're looking at is strictly DBIx::Class organization/methodology (from what I've read, at least.). It gets convoluted sometimes, but the separation is there to help *you* get to the root of your question and keep logic separate, etc.

    Hope this helps!

    meh.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://710081]
help
Chatterbox?
[stevieb]: atcroft: "Make both hands into fists..."... is something my Ma taught me in our native lang, but I was to ignorant and young to pay attention. Thanks for that :)
[atcroft]: stevieb: Sad to say that I only recently learned that particular trick, but I have since found it very useful.... :)
[james28909]: ill be back with a solution eventually
[stevieb]: it's a reminder to re-inforce it :P
[atcroft]: james28909: That particular questions was a bit of trick, actually (depending on the country you are in). More interesting is, if you are trying to subtract from an epoch time, for instance, you might have to consider when/if DST occurs for a location,
[atcroft]: because you may have to adjust the number of seconds you change from an epoch from 86400 (not to mention leap seconds)....
[atcroft]: james28909: Although if your program is using a database, you might be able to "pass the buck" to the database and ask it to do the date change for you....

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2017-04-29 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.