[Handel] Can't locate object method "items" via
package "Handel::Iterator
Christopher H. Laco
claco at chrislaco.com
Thu Sep 29 17:13:12 CEST 2005
Bernard FRIT wrote:
> Hi,
>
> Just using Handel 0.24 with Catalyst I got the above message when
> executing the following code :
>
> sub weight : Private {
> my ($self, $c) = @_;
> my $weight ;
>
> my $order = Handel::Order->load({
> id => $c->stash->{'orderid'}
> }, RETURNAS_ITERATOR
> );
At this point, $order ISA Handel::Iterator.
> my $iterator = $order->items;
Now, as the message states, we're trying to call the
Handel::Iterator::items method, which doesn't exist.
Instead, change the first part to get the first order found:
my $order = Handel::Order->load({
id => $c->stash->{'orderid'}
}, RETURNAS_ITERATOR
)->first;
Now, $order ISA Handel::Order, and $order->items will do what you want.
Now with that said, I'll claim responsibility for these sorts of
problems. Early on, I tried to make too load()/items() smart about what
they returned.
If there was one item, I'd return an item instance instead of an
interator. The same goes when loading carts or orders. Sometimes, that
behaviour sucked, so I tossed in the RETURN_AS constants to let users
specify what they really want (and to fix some obscure things under TT
wnar wantarray). Things are no way too complicated.
At some point in the future, I plan on ditching all of the mess in
favour of always returning a Handel::Iterator. Since that will be a big
breaking API change, I'll save it for 1.0.
On a more positive note, thanks for using Handel! :-)
-=Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3178 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.rawmode.org/pipermail/handel/attachments/20050929/6659d68a/smime.bin
More information about the Handel
mailing list