[Zope] python script looping

Hamzat Kamal hamzatk at dnetsystems.net
Tue Jul 13 10:03:30 EDT 2004


Thanks it works.


At 09:31 AM 7/13/2004 -0400, you wrote:
>From: Hamzat Kamal
> >I am getting
> >Error Type: TypeError
> >Error Value: unsliceable object
> >
> >when i ran this python script
> >
> >yymmdd='040712'
> >for i in container.pictures.objectValues(['Image']):
> >        if yymmdd==i.id[5:11]:
> >            return i.title
> >
> >the pictures is the name of folder that contain the images but i want the
>script to be in the same container as the >pictures.
>
>I think you want something like:
>
>yymmdd='040712'
>for i in container.picture.objectItems(['DTML Method']):
>    sid = str(i[0])
>    if yymmdd==sid[5:11]:
>       return i[1].title_or_id()
>
>However, this will only return the first instance where the id of the file
>object matches the contents of yymmdd. If you want to return all matches
>then you need something like:
>
>idlist=[]
>yymmdd='040712'
>for i in container.picture.objectItems(['DTML Method']):
>    sid = str(i[0])
>    if yymmdd==sid[5:11]:
>       idlist.append( i[1].title_or_id() )
>
>return idlist
>
>
>HTH
>
>Jonathan




More information about the Zope mailing list