how-to generate a DTMLMethod from a random zClass in a Folder???
Q: I want to generate the DTMLMethod "foo" from a randomly selected zClass in the Folder "bar". As a newbie to developing and to Zope, I have hit a wall with this one... So far, I have randomly generated images, and randomly generated ID's for cookies...but the same approach does not seem to be working on zclass methods. If this helps, I can generate a DTMLmethod using... <dtml-with bar> <dtml-with azClassID> <dtml-var foo> </dtml-with> </dtml-with> i stopped here... <dtml-var expr="_.random.choice(bar.objectValues('id').foo)"> Would it work better if "foo" was a DTMLDocument? I cant find any reference to something like this, so maybe this will become my first how-to. Thanks for the help, -Trevor
Maybe someone can check my logic...? please. <dtml-with folderwithmyZclasses> <dtml-var expr="_.random.choice(objectValues('myZclass').myZclassDTMLmethod)"> </dtml-with> RETURNS:: Error Type: AttributeError Error Value: myZclassDTMLmethod And this doesnt work...<dtml-var expr="_.random.choice(objectValues(['myZclass']).objectValues(['myZclassDTML method']))"> 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> TIA, -Trevor
Q: I want to generate the DTMLMethod "foo" from a randomly selected zClass in the Folder "bar".
As a newbie to developing and to Zope, I have hit a wall with this one... So far, I have randomly generated images, and randomly generated ID's for cookies...but the same approach does not seem to be working on zclass methods.
If this helps, I can generate a DTMLmethod using... <dtml-with bar> <dtml-with azClassID> <dtml-var foo> </dtml-with> </dtml-with>
i stopped here... <dtml-var expr="_.random.choice(bar.objectValues('id').foo)">
Would it work better if "foo" was a DTMLDocument? I cant find any reference to something like this, so maybe this will become my first how-to. Thanks for the help, -Trevor
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Maybe someone can check my logic...? please. <dtml-with folderwithmyZclasses> <dtml-var expr="_.random.choice(objectValues('myZclass').myZclassDTMLmethod)"> </dtml-with>
<dtml-with folderwithmyZclasses> <dtml-var expr="_.random.choice(objectValues('myZclass')).myZclassDTMLmethod(_.None,_) "
</dtml-with> cheers, Chris PS: DTML and logic in your presentation layer is another route to misery and pain ;-) I'd recommend Python Scripts and ZPT...
<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
participants (2)
-
Chris Withers -
Trevor Toenjes