[Dbix-class] Handel 1.0 + DBIC
Christopher H. Laco
claco at chrislaco.com
Wed Mar 29 17:57:38 CEST 2006
Warning: wild incoherent rambling and pseudo code ahead!
OK, I really want to start working on a Catalyst/Handel ecomm package.
But before I venture that way, I guess I need to get Handel converted to
DBIC so I can retain my future sanity.
For the purposes of this discussion, lets keep to Handel::Cart. It's a
Handel::DBI subclass, which is a Class::DBI subcless.
Handel::Cart
-> Handel::DBI
-> Class::DBI
If people want to add custom fields, they simply alter the DB, subclass
Handel::Cart, and call add_columns to add the new columns.
Custom::Cart
-> Handel::Cart
-> Handel::DBI
-> Class::DBI
CustomeCart->add_columns(qw/foo bar baz/);
Pretty straight forward, but a PITA at some level to expose an API
without trampling on the CDBI API or causes deep recursions.
--
In 1.0, I want to move away from ISA towards delegation. Considering I'm
behind the DBIC curve, I'm having a hard time with conceptualizing how
to hide DBIC behind the scenes and delegate things like Schema Results
sets into other classes (Schema::Cart::Item bubbles up to the user as a
Handel::Cart::Item instance). First, creating the Schema is pretty
straight forward:
Handel::Cart::Schema->load_classes
Handel::Schema::Cart
Handel::Schema::Cart::Item
Handel::Cart
$self->{schema} = Handel::Cart::Schema->connect
First things first. If users want to add custom fields to the cart,
what's the best way? I can think of two: customize the schema before
connect, or let them make their own schema:
CustomCart
-> Handel::Cart
CustomCart->add_columns(qw/foo bar baz/)
This calls
Handel::Cart::Schema->class('Handel::Schema::Cart')->add_columns
or
CustomerCart
-> Handel::Cart
CustomCart->schema = CustomeCarT::Schema->connect
I'm sure some tinkering will sort it out, but I'm not sure which
direction to try first.
Second, what's the best way to use resultset behind the scenes, but have
their results present as non-Schema objects?
For example:
my @items = $cart->items();
Right now, that returns an array of Handel::Cart::Item objects.
In Schematown, that might look like:
Cart::items()
@items = $self->{schema}->{'Handel::Schema::Cart::Item'}->all;
return map {Handel::Cart::Item->new(resultset=>$_}, @items;
Is that even sane? What's the best way to represent the resultset
results as other things?
If any of this makes any sense, I owe you a beer. :-)
-=Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060329/e244fe72/attachment-0001.pgp
More information about the Dbix-class
mailing list