[Handel] Basic Handel w/o Catalyst questions

Christopher H. Laco claco at chrislaco.com
Mon Oct 30 13:53:01 GMT 2006


Curtis Fletcher wrote:
> Hi all

Wow. That's a big question. :-)

> =

> I'm writing (yet another) basic cart app for my current company so I
> thought I'd take a look at Handel. Now I'm looking at using Catalyst for
> some of out internal UI stuff but not on out externally facing machines.
> Are there any quick start guides for using handel without Catalyst?
> Neither is mod_perl really an option so without a persistent environment
> what sort of setup would you need per-CGI (__PACKAGE__ style
> declarations and the suchlike) to make the handel objects available and
> useful?

Well, it's just a set of modules to do cart/order/checkout IO. How it's
used is up to the user; be it Catalyst, shell scripts, mod_perl, etc.

If you want to use Handel without using Catalyst (they're not tied to
each other), you will have to write something. What that something is is
up to you and what you like to work in. CGI::Application, .cgi, TT,
Mason, etc.

There are some files in the /demos directory, but they're old and hacky.
What's the reason you don't want to use Cat on the external facing stuffs?

> =

> I've looked at the new subclass-generator and have been trying to trace
> back to find out which methods I need to override. And I'm having a
> little trouble wrapping my head around what I'd need to subclass to use
> multiple currencies.

By 'new subclass generator', do you mean Module::Starter::Handel?
http://handelframework.com/blog/new_features/modulestarterhandel/

Everything it generates is non-Catalyst, and even non-web related. To
use it in a Cat app, you just copy it into the Cat apps lib directory,
or just in stall the modules like any other perl modules.

> =

> Basically my company has 3 prices for each item (USD/GBP/AUD) and the
> country is declared upfront then it only shows you those prices. So
> would I be subclassing something in the Handel::Storage::DBIC hierarchy
> and altering which column is considered "cost" for each of the 3
> variants or can anyone think of a better way to start?

Well, it depends. From your description, it sounds like you have some
store/product related code that takes care of deciding what price or the
three to show. (*Handel is cart/orders/checkout only, so the product
storage and display code is out of its realm).

Once a part is added to the cart, it needs to remember which country
price it is, and each item in the db (for different customers) could
have different countries.

Luckily, I just added something for Kaare last week to make this easier.
In Storage, there is a new setting called currency_code_column().

When set, the price objects for each row will look at the specified
column for the given country code.

So, let's say you have the following schema:

cart_items:
  id
  cart,
  sku
  price
  code

and the following data:

  1, 1, ABC-1, 1.23, CAD
  2, 1, ABC-2, 1.54, USD

In your storage class, you set the currency code column:
> =

> package MyProject::Storage::Cart::Item;
> ...
> __PACKAGE__->currency_code_column('code');

Now, when you load those items and use the price field, they are set to
their correct currency code:

  my $items =3D $cart->items;
  while (my $item =3D $items->next) {
    print $item->price->format;
  };

you get something like this:

  # $1.23 Canadian Dollars
  # $1.54 US Dollars

Hopefully, some of that make some sense... :-)
I tend to ramble.

See the Cookbook pod on CPAN for info on how to add columns to the
default schema.

> =

> If any of these questions have been answered please just point me in the
> right direction.
> =

> Hey if there isn't a non-Catalyst quickstart guide if I can get my head
> around it I'll write one myself (I have to say though after looking at
> Handel and Catalyst I feel like I've fallen into some alternate universe
> where perl is similar but not quite that same as the perl I'm used to.
> :) )


Oh, you mean organized. :-)
There is actually a QuickStart.pod. I haven't filled it out yet because
I hadn't yet written Module::Starter::Handel.


> =

> Curtis Fletcher
> Software Developer
> =

> _______________________________________________
> Handel mailing list
> Handel at lists.rawmode.org
> http://lists.rawmode.org/cgi-bin/mailman/listinfo/handel
> =

> =



* I really should change the title of Handel from

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

to

"A cart/order/checkout framework with AxKit/TT/Catalyst support."

...since it really has nothing to do with products, catalogs, or
building the rest of websites outside of the cart/order/checkout realm.

-=3DChris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://jules.scsys.co.uk/pipermail/handel/attachments/20061030/32287d=
38/signature.pgp


More information about the Handel mailing list