How do I get the value of an object in python???
How do I get the value of an object in python and then pass it's attributes to a DTML method???? I run the following:
## Look for Day Year (ie - Monday 2003) for i in container.StyleBook.objectValues('Style Sheet') : print container.StyleBook.loadStyle(title=i.title, styletype=i.styletype, bodycolor=i.bodycolor ) return printed
and it runs fine against loadStyle - a DTML method I wrote to return a formatted CSS stylesheet..... But what I would like to do is use loadStyle in the context of i - in other words, use i's attributes as properties to loadStyle WITHOUT having to declare them all as arguments to loadStyle. What I cant figure out is, how do I get i's id and then pass it to container.StyleBook.loadStyle (python doesnt seem to like container.StyleBook.i.loadStyle) How does one do this? TIA WPH
Bill Hewitt wrote at 2003-8-24 09:03 -0700:
...
## Look for Day Year (ie - Monday 2003) for i in container.StyleBook.objectValues('Style Sheet') : print container.StyleBook.loadStyle(title=i.title, styletype=i.styletype, bodycolor=i.bodycolor ) return printed
and it runs fine against loadStyle - a DTML method I wrote to return a formatted CSS stylesheet.....
But what I would like to do is use loadStyle in the context of i - in other words, use i's attributes as properties to loadStyle WITHOUT having to declare them all as arguments to loadStyle.
Almost surely, the following will work: ... loadStyle(i,container.REQUEST) ... The full solution will be to bind the DTML namespace in your Python Script (usually called '_') and use ... loadStyle(i,_) ... This will pass the DTML namespace from a DTML object through the Python Script to "loadStyle" (in case you need this; which is probably not the case). Please read "Calling DTML objects" in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> Dieter
participants (2)
-
Bill Hewitt -
Dieter Maurer