Jonathan Rockway wrote:
functionality. If I put the functionality in the Schema::*, I will
have about 400 lines of code that I need to replicate across eight or
more sites and the classes won't be usable without DBIx::Class or
Catalyst.
No, your current solution is the one that's not usable without Catalyst
and DBIC.
That's a weird conclusion... I admit that the example I posted was not
very descriptive of my solution. (There were even some omissions, like
"use Moose".) What I have done in the real applications is more
something like:
package TestApp::Model::Foo::Bar;
use Moose;
extends 'RW::Bar';
1;
Where RW::Bar is the class with the actual functionality, completely
independent of DBIC or any other storage solution.
If you just want some random classes, you write them:
package Class;
...
1;
I usually "wrap" the DBIC classes like this when I have operations that
logically operate on a group of "unrelated" (in the DB) objects, or
operate on two separate schemas. (What most people do in the controller
I do in what I call "Backend" classes. It's the glue between the
low-level DBIC stuff, and high-level operations.)
Your example does not show how Class is being used or how an object is
created/inflated, but illustrates *basically* what I want to do.
If your classes depend on the structure of DBIC results, then the code
needs to go in your schema classes. That is how everyone does it.
(Your "full_name" example is just the sort of thing that you would keep
inside DBIC.)
My classes don't depend on the structure. I only want to initialize
objects with values that sometimes happen to come from a database. I was
under the impression that this initalization can easily be done with
DBIC, but I still haven't seen an example of a class with more complex
functionality. I guess I could just use HashRefInflator and create my
objects from hashrefs, but that involves a bit more repetitious code.
As I said before, the full_name example has nothing to do with my
application. It was only for illustration.
Regards,
Alex
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/