On 5/23/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
I'm wondering what the normal 'layout' is for files / packages under
mod_perl

Mod-perl or not, the most flexible way to handle things is to make a
bunch of (trivial) subclasses first to hold all your customizations
down the road, then base all your real classes off those.  Here's an
example from the fictional PDQ corporation:

The base classes:

* PDQ::DB - Rose::DB subclass, all data sources registered here

* PDQ::DB::Object - Rose::DB::Object subclass with init_db overridden
to return a PDQ::DB object

* PDQ::DB::Object::Cached - (Optional) subclass of
Rose::DB::Object::Cached and PDQ::DB::Object, used as a base class for
any cached objects.

* PDQ::DB::Object::Manager - (Optional) Rose::DB::Object::Manager
subclass, in case you want to add methods to all your managers.

Then some real classes:

* PDQ::Product - isa PDQ::DB::Object

* PDQ::Product::Manager - isa PDQ::DB::Object::Manager, or isa
Rose::DB::Object::Manager if you don't have a custom manager base
class.

* PDQ::Category - isa PDQ::DB::Object::Cached

...and so on.  I tend not to have ::Cached and "regular" classes
fronting the same table.  If a table contains cache-able stuff, then I
just make the class inherit from ::Cached and that's it.  (I don't put
::Cached in the class name in that case.)  But you can have ::Cached
and non-cached classes for the same table if that's what you want.

I also flip-flop between putting ::DB:: in the real class names or
not.  For example PDQ::Product vs. PDQ::DB::Product.  It all depends
on how crowded the PDQ:: namespace is expected to be.

As for file paths, just translate all the "::"s above into "/"s and
add "lib/" to the front and ".pm" to the end:

   PDQ::DB::Object  -> lib/PDQ/DB/Object.pm

But that's just standard Perl 5 practice.

I'm also repeating a lot of the column info... is there a typical way to
declare column info 1x, then just derive / subclass into the different
object types ?

Sure, just do what you said: subclass.  Subclasses get a one-time deep
copy of the parent class's metadata.  Read the "Inheritance" section
of the docs for more info and examples:

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object.pm#Inheritance

-John


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid7521&bid$8729&dat1642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to