Interrogating DTML values from within an External method
I've spent all morning on this and searched the Zope and ZDP site to no avail. How do I get values of dtml variables defined in a DTML document from within an external method? <dtml-in question_set> - defined as a property in the enclosing folder. Use self.question_set - ok. <dtml-let qidx="_['sequence-item']"> - a variable created in the document. I use self.qidx and get Error type: AttributeError Error value: qidx Using REQUEST.qidx I get Error type: KeyError Error value: qidx Using REQUEST['qidx'] returns Error type: KeyError Error value: qidx Ideally I want to get the value of a variable created from a ZSQL method, <dtml-in "get_question(code=qidx)"> (variable correct defined by get_question ZSQL) </dtml-in> but that's not working either. *ANY* thoughts would be appreciated. tone ------ Dr Tony McDonald, FMCC, Networked Learning Environments Project http://nle.ncl.ac.uk/ The Medical School, Newcastle University Tel: +44 191 222 5888 Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2
At 01:08 PM 7/29/99 +0100, Tony McDonald wrote:
I've spent all morning on this and searched the Zope and ZDP site to no avail.
How do I get values of dtml variables defined in a DTML document from within an external method?
Well, noone else seems to have answered this one, so I think I'll take a stab at this. Note that I haven't done much programming in Zope2, so this all applies to Zope 1.10.x, although I don't think it should make a difference. Anyway, the way I've always done it is to explicitly name the variables and not bother trying to use the REQUEST. So, my function would look like this: def ExternalMethod(self, var1, var2): and my dtml call to it would be: <!--#var "ExternalMethod(var1=var1, var2=var2)"--> Then thing about the self variable that gets passed in (I think) is it passes in a reference to the folder, not the dtml document. At least I use it to call other methods using self.somemethod. Hope this helps a bit. Nick Garcia | ngarcia@codeit.com CodeIt Computing | http://codeit.com
hink it should make a difference.
Anyway, the way I've always done it is to explicitly name the variables and not bother trying to use the REQUEST. So, my function would look like this:
def ExternalMethod(self, var1, var2):
and my dtml call to it would be: <!--#var "ExternalMethod(var1=var1, var2=var2)"-->
Then thing about the self variable that gets passed in (I think) is it passes in a reference to the folder, not the dtml document. At least I use it to call other methods using self.somemethod.
Hope this helps a bit.
Thanks for the reply Nick, I've taken to passing my variables this way rather than relying on my pretty meagre knowledge of namespaces! thanks tone. ------ Dr Tony McDonald, FMCC, Networked Learning Environments Project http://nle.ncl.ac.uk/ The Medical School, Newcastle University Tel: +44 191 222 5888 Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2
participants (2)
-
Nick Garcia -
Tony McDonald