Bill Moseley wrote:
> This is suppose to be an ORM-neutral question.
> 
> I often use lookup tables in the database, even for things like, say,
> cart_status:
> 
>     create table cart_status (
>         id      SERIAL PRIMARY KEY,
>         name    text NOT NULL,
>         active  boolean NOT NULL DEFAULT TRUE
>     );
> 
>     -- trust the sequence, Luke
>     insert into cart_status (name) values ('Pending');
>     insert into cart_status (name) values ('Completed');
> 
> Then things like this are nice:
> 
>     [% cart.cart_status.name %]
> 
> And can do this:
> 
>     update cart_status set name = 'Finished' where name = 'Completed';
> 
> And add new lookup options:
> 
>     insert into cart_status (name) values ('Orphaned');
> 
> 
> but this is not so nice:
> 
>     $cart_class->search( cart_status => 1 );
> 
> 
> So, what have you found that works nicely?
> 
>     use MyApp::Const qw/ cart_pending /;  # potentially long list
>     cart_status => cart_pending  # runtime checking
> 
>     use MyApp::Const qw/ :cart /; # Shorter list :)
> 
> 
>     cart_status => MyApp::CONST::pending, # global constants
> 
> 
>     # Make it very clear where a constant should be used
>     # by adding the constants as methods to the cart namespace
> 
>     cart_status => $cart_class->pending_status
> 
> 
> 
> 
> 

And why aren't you using Handel? :-)

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to