[Zope] how-to generate a DTMLMethod from a random zClass in a Folder???
Trevor Toenjes
zope@toenjes.com
Mon, 10 Sep 2001 15:16:32 -0400
> <dtml-with folderwithmyZclasses>
> <dtml-var
expr="_.random.choice(objectValues('myZclass')).myZclassDTMLmethod
> (_.None,_)"
> </dtml-with>
>
Thanks, Chris,
This got me closer. ;) However, I thought it acquired the namespace of the
randomly selected 'myZclass'.
NOW,
I am getting...
Error Type: NameError
Error Value: global name 'headline' is not defined
**"headline" is in the PropertySheet of 'myZclass'...which is called in
'myZclassDTMLmethod'.
I have spent another day on this and have been rereading Zope Book:Appendix
B/DTMLMethod docs and still cant figure out the namespace syntax to correct
this.
Do I need REQUEST around random or in the method call?
something like
"_.random.choice(objectValues('myZclass')).myZclassDTMLmethod(_.myZclass,_)"
I even tried to generate a random dtml-with...ha ha.
<dtml-with
"folderwithZclasses.random.choice(folderwithZclasses).objectValues('myZclass
')">
<dtml-var myZclassDTMLmethod>
</dtml-with>
I included this as a working reference.
So far...this is working. This displays "myZclassDTMLmethod" for every
'myZclass' in the "folderwithmyZclasses" folder.
<dtml-with folderwithZclasses>
<dtml-in "objectValues(['myZclass'])">
<li><dtml-var myZclassDTMLmethod>
</dtml-in>
</dtml-with>
This answer should help me understand the magic a little more.
It looks like products and classes are my future, when I get these zClasses
working.
Thanks,
Trevor