[Zope] How the heck do I do this Python for Loop?

Samir Mishra SamirMishra at cbuae.gov.ae
Mon Aug 25 14:17:13 EDT 2003


Use something along the lines of -
obj = getattr(container.stylebook, i)
return obj.loadStyle()

-----Original Message-----
From: Bill Hewitt [mailto:wphewitt at comcast.net]
Sent: Monday, August 25, 2003 10:07
To: zope at zope.org
Subject: [Zope] How the heck do I do this Python for Loop?


This has been driving me crazy for the last week......

I wrote a python script that loops through a directory called StyleBook
and selects a particular stylesheet based on the Day of the week, the
year and a parameter.....
---------
example:
---------

## Look for Day Year (ie - Monday 2003) in the StyleBook Directory
for i in container.StyleBook.objectValues('Style Sheet'):

 ## Check the TITLE of "i" against a preset variable and  aparameter
 if i.title = DAYYEAR and i.stylesheetrequest == stylesheetrequest:
   ### At this point I have all the variables (47 total) except the ID
:( 

This works - I get the proper Style Sheet.... 

I would *like* to then call a DTML Method against the values in the
NAMESPACE of the object I found in the code above.....

something like

return container.StyleBook.i.loadStyle()

but every variation I have tried doesnt work - I get an error telling me
that "i" is not in the global NameSpace....


Could someone PLEASE help me through this one? I know it is probably
very simple, but it is evading me...

WPH





_______________________________________________
Zope maillist  -  Zope at zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )



More information about the Zope mailing list