[Handel] Handel-0.99_05 getting started
ryan lauterbach
ryan at radianit.com
Tue Aug 22 17:21:34 CEST 2006
wow, thanks for the all info Chris, I gather you're busy gettin 1.00 out
de do'.
Keep up the good work
Christopher H. Laco wrote:
> ryan lauterbach wrote:
>
>> Hi,
>>
>> I'm trying to add the Handel cart to an existing site which uses
>> Catalyst 5.7001 with DBIx::Class::Schema models. When I run the
>> Handel::Scaffold helper I get a Cart model looking like:
>>
>> package App::M::Cart;
>> use strict;
>> use warnings;
>> use base qw/Handel::Cart/;
>>
>> __PACKAGE__->connection_info('dbi:mysql:dbname', 'bleh', 'bleh');
>>
>> 1;
>>
>> Now is it possible to use my existing Schema connection info? I also
>> get this error in the apache log:
>>
>> Can't locate object method "connection_info"
>>
>> Maybe the helper is still creating a Class::DBI type model??
>>
>
> OK. Bad news first. All of the Catalyst helper code needs to be
> rewritten in 0.99_0x. The code included in the dist is the old 0.33
> code. That process hasn't been started in earnest since I'm still
> refactoring the Storage layer. :-/
>
> As soon as I'm done writing tests and pod for the Storage/Storage::DBIC
> stuffs, it is my #1 priority.
>
>> Also is there an example schema somewhere of how to create the cart,
>>
>
> http://search.cpan.org/src/CLACO/Handel-0.99_05/sql/handel.sqlite.sql
>
>
>> checkout, order database tables? Or a tutorial to follow or something,
>> couldn't see how to bootstrap this thing from the cpan docs.
>>
>
> Yeah. That last big set of pod on my list is Tuts or Cookbookage on
> initial setup and customizing tables/schemas.
>
>
>> Many thanks!
>>
>> Ryan
>>
>
> Now, as for the mode problem, this may help (see attached files). It's
> what I have on my USB stick at the moment. Just copy Cart ro Order and
> change the appropriate class_name bits...
>
> Connection info can be set using:
>
> __PACKAGE__->config(
> connection_info => []
> )
>
> in the apps models, or you can set it in the yml file:
>
> Mode::Cart:
> connection_info:
> - dbi:Sqlite:handel.db
>
> etc...Alternatively, this might work (untested):
>
>
>
>> package App::M::Cart;
>> use strict;
>> use warnings;
>> use base qw/Handel::Cart/;
>>
>> __PACKAGE__->storage->connection_info(['dbi:mysql:dbname', 'bleh', 'bleh']);
>>
>> 1;
>>
>
> If you're using the existing helper code, you're going to get bit by
> template names as well...so you may need to set TEMPLATE_EXTENSION =>
> '.tt' as well.
>
> Unfortunately, 0.99_0x are dev releases, so you're un as-yet uncharted
> waters.
>
> -=Chris
>
> ------------------------------------------------------------------------
>
> # $Id$
> package Catalyst::Model::Handel::Cart;
> use strict;
> use warnings;
>
> BEGIN {
> use base qw/Catalyst::Model Class::Accessor::Grouped/;
> use Class::Inspector;
> use Catalyst::Exception;
> };
>
> __PACKAGE__->mk_group_accessors('inherited', qw/cart_manager/);
>
> sub COMPONENT {
> my $self = shift->SUPER::new(@_);
> my $cart_class = $self->{'cart_class'} || 'Handel::Cart';
>
> if (!Class::Inspector->loaded($cart_class)) {
> eval "use $cart_class"; ## no critic;
> if ($@) {
> Catalyst::Exception->throw(message => "Could not load cart class $cart_class: $@");
> };
> };
>
> my $manager = bless {
> storage => $cart_class->storage->clone
> }, $cart_class;
>
> foreach my $key (keys %{$self}) {
> if ($manager->storage->can($key)) {
> $manager->storage->$key($self->{$key});
> };
> };
>
> $self->cart_manager($manager);
>
> return $self;
> };
>
> sub new {
> return shift->cart_manager->new(@_);
> };
>
> sub AUTOLOAD {
> my ($method) = (our $AUTOLOAD =~ /([^:]+)$/);
>
> return if $method =~ /(DESTROY|ACCEPT_CONTEXT)/;
>
> return shift->cart_manager->$method(@_);
> };
>
> 1;
>
> ------------------------------------------------------------------------
>
> package HandelDemo::Model::Cart;
> use strict;
> use warnings;
>
> BEGIN {
> use base qw/Catalyst::Model::Handel::Cart/;
> };
>
> __PACKAGE__->config(
> connection_info => ['dbi:SQLite:handel.db']
> );
>
> 1;
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Handel mailing list
> Handel at lists.rawmode.org
> http://lists.rawmode.org/cgi-bin/mailman/listinfo/handel
>
More information about the Handel
mailing list