I've gone about it this way, and although the business logic is not within Catalyst, somehow, what I've done doesn't feel right.<br><br>In myapp_server.pl I've had to add a few paths to @INC<br>use lib "/home/anthony/devel/lib";<br>use lib "/home/anthony/devel/lib/Test"<br><br>For my business layout I have ...<br><br>~/devel/lib/Test/TestSchema.pm<br>~/devel/lib/Test/TestSchema/UserProfile.pm<br>~/devel/lib/Test/Model/UserProfile.pm (see snippet two)<br>~/devel/lib/Test/Model/Base.pm (see snippet three)<br><br>Then I have for Catalyst<br><br>~/dev/websites/MyApp/lib/MyApp/Model/UserProfile.pm (see snippet one)<br><br>########### (snippet one)<br><br>package MyApp::Model::UserProfile;<br><br>use strict;<br>use base 'Catalyst::Model::DBIC::Schema';<br><br>use Test::Model::UserProfile;<br><br>__PACKAGE__-&gt;config(<br>&nbsp;&nbsp;&nbsp; schema_class =&gt; 'Test::TroveSchema',<br>&nbsp;&nbsp;&nbsp; connect_info =&gt; [<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 'dbi:SQLite:db/test.db',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '',<br><br>&nbsp;&nbsp;&nbsp; ],<br>);<br><br>sub new {<br>&nbsp; my $class = shift;<br>&nbsp; my $c = shift;<br>&nbsp; my $args = shift;<br><br>&nbsp; my $merged_args = Catalyst::Utils::merge_hashes( $args, $class-&gt;config() );<br>&nbsp; return Test::Model::UserProfile-&gt;new( $merged_args );<br><br>}<br><br>######################## (snippet two)<br><br><br>package Test::Model::UserProfile;<br><br>use strict;<br><br>use base 'Test::Model::Base';<br><br>&lt;methods&gt;<br><br>################## (snippet three)<br><br>package Test::Model::Base;<br><br>use base 'Class::Accessor';<br><br>use Carp;<br><br>use Test::TroveSchema;<br><br><br>__PACKAGE__-&gt;mk_accessors(qw|schema|);<br><br>sub new {<br>&nbsp; my $class = shift;<br>&nbsp; my $self = $class-&gt;next::method(@_);<br><br>&nbsp; croak "-&gt;connect_info must be defined" unless(
 $self-&gt;{connect_info} );<br><br>&nbsp; $self-&gt;{schema} = Test::TroveSchema-&gt;connect( @{ $self-&gt;{connect_info} } );<br><br>&nbsp; $self<br>}<br><br>sub find {<br>&nbsp; my $self = shift;<br>&nbsp; my $id = shift;<br><br>&nbsp; my $calling_pkg = (caller(0))[0];<br>&nbsp; $calling_pkg =~ s|(.*)::(.*)$|$2|;<br><br>&nbsp; return $self-&gt;{'schema'}-&gt;resultset($calling_pkg)-&gt;find($id);<br>}<br><br>Now, what seems wrong to me is that I've had to write new() methods and also, for example, a find() method which is in Test::Model::Base. This doesn't seem right to me.I would've thought I would have all of DBIC's utils available to me without having to recall them.<br><br>Can anyone offer pointers?<br><br>Many thanks<br><br>-Ants<br><br><b><i>Matt S Trout &lt;dbix-class@trout.me.uk&gt;</i></b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> On Thu, Sep 27, 2007 at 11:51:26AM +0100, Ian Docherty
 wrote:<br>&gt; In a previous thread, Matt S Trout said.<br>&gt; <br>&gt; &gt;The model -is- where your business logic lives.<br>&gt; &gt;<br>&gt; &gt;The real question is whether your ORM should be directly in the model or<br>&gt; &gt;not, but that's a whole different thread.<br>&gt; <br>&gt; Based on this I have the following simple code.<br>&gt; <br>&gt; ####<br>&gt; package MyApp::Model::DBIC;<br>&gt; <br>&gt; use strict;<br>&gt; use base qw(Catalyst::Model::DBIC::Schema);<br>&gt; <br>&gt; ####<br>&gt; package MyApp::Schema::Demo;<br>&gt; <br>&gt; use base qw(DBIx::Class);<br>&gt; <br>&gt; __PACKAGE__-&gt;load_components(qw(PK::Auto Core));<br>&gt; __PACKAGE__-&gt;table('demo');<br>&gt; __PACKAGE__-&gt;add_columns(qw(id name state));<br>&gt; __PACKAGE__-&gt;set_primary_key('id');<br>&gt; <br>&gt; <br>&gt; ####<br>&gt; package MyApp::Model::DBIC::Demo;<br><br>Put this code in MyApp::Schema::Demo.<br><br>I often call it e.g. MyApp::DataStore or MyApp::Domain to remind me
 that<br>it's the business layer and the DBIC-ness is merely incidental.<br> <br>&gt; sub do_some_business_logic_stuff {<br>&gt;    my ($self) = @_;<br>&gt; <br>&gt;    if (<some complicated="" business="" logic="">) {<br>&gt;        $self-&gt;state('pending');<br>&gt;        $self-&gt;update;<br>&gt;    }<br>&gt; }   <br>&gt; <br>&gt; <br>&gt; #### somewhere in my application<br>&gt; <br>&gt; $demo = $c-&gt;model('DBIC::Demo')-&gt;find($index);<br>&gt; $demo-&gt;do_some_business_logic_stuff;<br>&gt; <br>&gt; -------------<br>&gt; <br>&gt; Is this a standard/typical/best-practice way to do this sort of thing? <br>&gt; <br>&gt; It seems to me that if I want to use the business logic in an external <br>&gt; application (cronjob) then I am having to use the MyApp::Model::DBIC::Demo <br>&gt; namespace as decreed by Catalyst (not that this is a big issue).<br><br>Having moved the logic out of MyApp::Model:: this ceases to be an issue.<br><br>Don't confuse class -names- with the
 nature of classes. MyApp::Model:: is<br>*adapters* that make a model available to MyApp, not where your domain model<br>logic itself should live.<br><br>I usually these days have MyApp::Web for the catalyst app instead of MyApp so<br>I can deploy things like MyApp::DataStore from a separate dir tree.<br><br>-- <br>      Matt S Trout       Need help with your Catalyst or DBIx::Class project?<br>   Technical Director                    http://www.shadowcat.co.uk/catalyst/<br> Shadowcat Systems Ltd.  Want a managed development or deployment platform?<br>http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/<br><br>_______________________________________________<br>List: Catalyst@lists.rawmode.org<br>Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst<br>Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/<br>Dev site: http://dev.catalyst.perl.org/<br></some></blockquote><br><BR><BR>Disclaimer: Technically, I'm always
 wrong!!<p>&#32;
      <hr size=1> 
Yahoo! Answers - Get better answers from someone who knows. <a
href="http://uk.answers.yahoo.com/;_ylc=X3oDMTEydmViNG02BF9TAzIxMTQ3MTcxOTAEc2VjA21haWwEc2xrA3RhZ2xpbmU">Try
it now</a>.