[Zope] loop over non sequence !!!

Casey Duncan c.duncan@nlada.org
Thu, 29 Nov 2001 09:11:31 -0500


On Thursday 29 November 2001 08:45 am, sanjeev c s allegedly wrote:
> hello,
> I want to delete last item from a folder, everytime
> the method is called.
> suppose name of the folder is pics
> so in a DTML method i say
> ---------------------------------------------------
> <dtml-in expr="pics.objectValues()">
> <dtml-if sequence-end>
> <dtml-call "pics.manage_delObjects(id)">
> </dtml-if>
> </dtml-in>
> ----------------------------------------------
> i get a error saying
> Error Type: TypeError
> Error Value: loop over non-sequence
>
> Please help me.
> regards,
> Sanju.

Try:

<dtml-let last_id="pics.objectIds()[-1]">
  <dtml-call expr="pics.manage_delObjects(last_id)">
</dtml-let>

This would be much better as a Python script tho. Then it would be:

last_id = context.pics.objectIds()[-1]
context.pics.manage_delObjects(last_id)

hth,
/---------------------------------------------------\
  Casey Duncan, Sr. Web Developer
  National Legal Aid and Defender Association
  c.duncan@nlada.org
\---------------------------------------------------/