Handel Framework

A simple commerce framework with AxKit/TT/Catalyst support.

Christopher H. Laco

Author. Hacker. Eternal Perl Newbie.

<claco@chrislaco.com>

What It Is

[any material that should appear in print but not on the slide]

What It Isn't

[any material that should appear in print but not on the slide]

Goals

[any material that should appear in print but not on the slide]

Features / Buzzwords

[any material that should appear in print but not on the slide]

Easy Integration

[any material that should appear in print but not on the slide]

Interchangable Schemas

[any material that should appear in print but not on the slide]

Interchangable Schemas: Accessor

package My::Schema::Cart;
use base qw/Handel::Schema::Cart/;
__PACKAGE__->remove_columns('name');
__PACKAGE__->add_columns(my_name => {accessor=>'name'};
1;

package My::Schema::Cart;
use base qw/DBIx::Class/;
__PACKAGE__->table('my_carts');
__PACKAGE__->add_columns(qw/id shopper type description/);
__PACKAGE__->add_columns(my_name => {accessor=>'name'};
__PACKAGE__->has_many(
    items => 'Handel::Schema::Cart::Item',
    {'foreign.cart' => 'self.id'}
);
1;

Handel::Cart->storage->schema_class('My::Schema::Cart');
[any material that should appear in print but not on the slide]

Interchangable Schemas: Subclass

package MyCart::Item;
use base qw/Handel::Cart::Item/;

# schema class has qty instead of quantity
__PACKAGE__->storage->schema_class('My::Schema::Cart::Item');

# make quantity to keep total (quantity * price) / restore happy
sub quantity {
    return shift->qty(@_);
};

# or, tweak total and restore
sub total {
    my $self = shift;
    return $self->qty * $self->price;
};

1;
[any material that should appear in print but not on the slide]

Interchangable Schemas: The Works

[any material that should appear in print but not on the slide]

Swappable Storage Classes

[any material that should appear in print but not on the slide]

Swappable Storage Classes: Generic Storage

package MyFileStorage;
use base qw/Handel::Storage Class::Data::Accessor/;
__PACKAGE__->mk_classaccessor('file_name');
use MyFileMagic;

sub create {
    my ($self, $data) = @_;
    my $file = MyFileMagic->new($self->file_name, $data);

    return $self->result_class->create_instance($file, $self);
};

sub add_item {
    my ($self, $result, $data) = @_;
    my $file = $result->result_storage;
    my $item_file = MyFileMagic->new(
	$self->item_storage->file_name, $data);

    return $self->result_class->create_instance($item_file, $self);
};
[any material that should appear in print but not on the slide]

Swappable Storage Classes: Subclasses

package MyCartStorage;
use base qw/MyFileStorage/;
__PACKAGE__->file_name('carts.dat');
__PACKAGE__->item_storage_class('MyCartItemStorage');
1;

package MyCartItem::Storage;
use base qw/MyFileStorage/;
__PACKAGE__->file_name('cart_items.dat');
1;


Handel::Cart->storage_class('MyCartStorage');
Handel::Cart::Item->storage_class('MyCartItemStorage');


# writes cart to carts.dat
my $cart = Handel::Cart->create({...});
[any material that should appear in print but not on the slide]

Swappable Storage Classes: Again...

[any material that should appear in print but not on the slide]

Subclassing Made Easy: Module::Starter

$ ./module-starter --class=Module::Starter::Handel

Created MyProject
Created MyProject\lib\MyProject
Created MyProject\lib\MyProject\Cart.pm
Created MyProject\lib\MyProject\Cart
Created MyProject\lib\MyProject\Cart\Item.pm
Created MyProject\lib\MyProject\Storage
Created MyProject\lib\MyProject\Storage\Cart.pm
Created MyProject\lib\MyProject\Storage\Cart
Created MyProject\lib\MyProject\Storage\Cart\Item.pm
Created MyProject\lib\MyProject\Order.pm
Created MyProject\lib\MyProject\Order
Created MyProject\lib\MyProject\Order\Item.pm
Created MyProject\lib\MyProject\Storage\Order.pm
Created MyProject\lib\MyProject\Storage\Order
Created MyProject\lib\MyProject\Storage\Order\Item.pm
Created MyProject\lib\MyProject\Checkout.pm
...
[any material that should appear in print but not on the slide]

Column Constraints

[any material that should appear in print but not on the slide]

Column Validation

[any material that should appear in print but not on the slide]

Column Default Values

[any material that should appear in print but not on the slide]

Currency Formatting and Conversion

[any material that should appear in print but not on the slide]

Localizaton (L10N)

[any material that should appear in print but not on the slide]

More Information

[any material that should appear in print but not on the slide]