I just ran into that with an array of objects too.  It didn't show up
until I used the .sort('name') vmethod and I hit a list with only one
item.  Seems like a bug to me.  

I got around it by sorting the CDBI child objects in the has_many spec
and not using the .sort vmethod.

Eric 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bill
Moseley
Sent: Tuesday, December 04, 2007 7:45 PM
To: [email protected]
Subject: [Templates] Trying to remember the change

I noticed this in some old code (where "cart") is a Class::DBI object:

    items = cart.items;
    count = items.size;

I ran it on my dev machine and noticed that it was reporting a count of
eleven when it should be just one item.  Then I ran on an old machine
with 2.14 (which is probably when that application was
written) and it reports just one item.

    Dumper.dump( items )

shows me that's it's just a single object, and there seems to be eleven
hash keys in the blessed hash.

I also noticed a stash entry for "as_list":

 sub { return ref($_[0]) eq 'ARRAY' ? shift : [ shift ] };

So, seems like I should have:

    count = as_list( items ).size;


I'm trying to remember, is that the usual approach?





--
Bill Moseley
[EMAIL PROTECTED]


_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - -

This message is intended only for the personal and confidential use of the 
designated recipient(s) named above.  If you are not the intended recipient of 
this message you are hereby notified that any review, dissemination, 
distribution or copying of this message is strictly prohibited.  This 
communication is for information purposes only and should not be regarded as an 
offer to sell or as a solicitation of an offer to buy any financial product, an 
official confirmation of any transaction, or as an official statement of Lehman 
Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  
Therefore, we do not represent that this information is complete or accurate 
and it should not be relied upon as such.  All information is subject to change 
without notice.

--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within this 
communication (including any attachments) is not intended or written to be used 
and cannot be used for the purpose of (i) avoiding U.S. tax related penalties 
or (ii) promoting, marketing or recommending to another party any transaction 
or matter addressed herein.



_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to