[Catalyst] Guidelines on reuse for non-component code

Alexander Christian Westholm awestholm at broadband.com
Wed Jun 22 16:02:20 CEST 2005


	I imagine a lot of people are going to have code that they'll want to 
reuse amongst various Catalyst components, but which is specific enough 
to the Catalyst app that they would want this code bundled in with the 
rest of the component code (i.e., not in site_perl). I could have 
glossed over it, but it seems that the docs don't mention anything on 
this... I had initially tried to add some non-action code to my 
application class, and hoped components would inherit them, but that 
obviously doesn't work. A quick call to Data::Dumper later, and I 
confirmed that the lib/ directory created by catalyst.pl is included in 
@INC during runtime. This is under the test server, but presumably is 
true for all execution environments (I'm sure Catalyst isn't 
require()ing M/V/C components). Is it good practice to include code 
that will be used by multiple components in a module under lib/ ? This 
seems more sensible than implementing such code through inheritance 
from the application class, since it's not directly tied to serving the 
request. Some notes about this in the docs might be nice.

Alexander Westholm
Director of Information Technology
awestholm at broadband.com
301-273-2116 || 443-223-0998

More information about the Catalyst mailing list