Jamie Neil wrote: > Can anyone tell me the best way of wrapping a non catalyst perl module > in a Catalyst Model? > > I'm trying to setup the following stack: > > MyApp::Controller::Widget > MyApp::Model::Widget > MyApp::Logic::Widget > MyApp::Schema::DB > > where MyApp::Model::Widget is based on Catalyst::Model, contains the > configuration information for MyApp::Logic::Widget, and makes the > methods in MyApp::Logic::Widget available in MyApp::Controller::Widget > as $c->Model('Widget')->mymethod(...); > > MyApp::Schema::DB is a DBIC Schema which I want MyApp::Logic::Widget to > use for storage, but not just passed through to the Model in the same > way that Catalyst::Model::DBIC::Schema does. > > There is obviously more than one way to do this from looking at all the > other models on CPAN, but is there some kind of best practice? Should I > use AUTOLOAD, ACCEPT_CONTEXT, COMPONENT, override new or something else? > > I did see a very promising thread on this issue a few months ago, but > this question > (http://lists.scsys.co.uk/pipermail/dbix-class/2007-January/003289.html) > was never really answered. I've been going round and round in circles on > this for a couple of weeks now, so some pointers (or even better example > code) would be most welcome. >
You're right. It depends on a few things. Does the module you're wrapping have a new? Is it statefull? stateless? Is it self creating, or is it a factory that creates other things. Those are all factors. Personally, I almost always do: sub COMPONENT { my $self = NEXT::new diddle config...return $self }
signature.asc
Description: OpenPGP digital signature
_______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/