[Catalyst] How many models?
jjn1056 at yahoo.com
Thu Apr 26 22:51:57 GMT 2007
----- Original Message ----
From: Jamie Neil <jamie at versado.net>
To: catalyst at lists.rawmode.org
Sent: Thursday, April 26, 2007 5:02:24 PM
Subject: Re: [Catalyst] How many models?
John Napiorkowski wrote:
> I think the consensus is that it's best to create business logic type
> models outside of Catalyst and then build a simple wrapper model for
> it. That way you can use it for stuff like cron jobs and anything
> that doesn't live inside of Catalyst.
That's exactly what we're trying to do.
> Now I isolated the business logic for creating an account into the
> MyApp::Logic::Accounts package because for my system creating a new
> user is much more than just inserting a row into the Users database.
> The logic would using the MyApp::Schema::Users Class and some other
> classes and wrap all that into a neat interface.
Again, this is the direction we are going, however what I was concerned
about was that this way we would end up with a lot more database handles
that was necessary (we may have three or four models). Whilst this is
not a problem for a single application, we are planning on running many
instances sharing the same database server.
Of course I may just be misunderstanding how DBIx::Class works :)
To be honest I'm not so sure what DBIx::Class does for this, although I haven't had any trouble with the above approach scaling when I do heavy testing. I figure that you Catalyst application would create a database handle and then if you ran a cron job that would create it's own handle for it's lifetime.
If this was a problem you could probably override the DBIC connection class to first check to see how many open handles on a database exists before trying to create a new one. I'd check the DBIC documentation (which is extensive) or mailing list archives (also extensive) and if you can't get a good answer post to the DBIx:Class mailing list.
DBIC searchable archive: http://firstname.lastname@example.org/
Good luck! --John
Jamie Neil | <jamie at versado.net> | 0870 7777 454
Versado I.T. Services Ltd. | http://versado.net/ | 0845 450 1254
List: Catalyst at lists.rawmode.org
Searchable archive: http://email@example.com/
Dev site: http://dev.catalyst.perl.org/
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
More information about the Catalyst