[Zope] Weirdness with <dtml-in> and external methods.
Tony McDonald
tony.mcdonald@ncl.ac.uk
Fri, 6 Aug 1999 14:18:49 +0100
Hi all,
I have a situation where I pass some variables *from* an external
method, to some DTML, which then returns it to the external method
(which *then* presents the finished product to the user). Sounds
convoluted, and it is, but it's the only way I can think of that will
let me do initial processing (for speed), but will allow me to change
the actual layout displayed to the user without messing with external
products (it also seems more flexible).
As an example, here's a snippet from my external method
(make_html3.py) that will generate a <P> tag around some content,
given that the 'type' of element is text (I have quite a few, such as
'item' and 'modulecontributor')
if thetag == 'text':
if theclass: # does it have a class? used for Cascading Style Sheets.
html.seq_prefix = "<P CLASS='%s'>" % theclass
html = "<P CLASS='%s'>%s" % (theclass, content)
# html = self.Actors.RENDER.dopara(theclass=theclass,
content=content)
else:
html = "<P>%s" % content
return html
If the commented line is removed, and I comment the preceding one, my
DTML method (dopara) gets called;
<table><tr><td bgcolor=silver><dtml-var content></td></tr></table>
and all is well.
Now all is fine and dandy *until* I want to use <dtml-in constructs.
I want to do this because for one of my 'type's is an email address
for data on module contributors (title, address, tel etc.)
I've tried with full ZSQL queries and they didn't work (but they DO
work if I try them from
within the Zope framework). I ended up with this DTML, called
modulecontributor. SQLPhone is a folder
where I'm putting my SQL methods, one of which is info_from_email.
<table>
<tr><td colspan=2 bgcolor=silver>This data is being dynamically
generated from a database</td></tr>
<dtml-in "Actors.SQLPhone.info_from_email(email=content)">
<tr>
<td><dtml-var Title> <dtml-var Initials> <dtml-var Surname><td><td> </td>
</tr>
<tr>
<td>Department:</td><td><dtml-var Department_Name></td>
</tr>
</dtml-in>
</table>
the relevant Python looks like this
if theclass == 'modulecontributor':
html = self.Actors.RENDER.modulecontributor(content=content)
return html
and the traceback :( looks like this...
<!--
Traceback (innermost last):
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/ZPublisher/Publis
h.py, line 256, in publish_module
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/ZPublisher/Publis
h.py, line 161, in publish
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/ZPublisher/mapply
.py, line 154, in mapply
(Object: cascade2)
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/ZPublisher/Publis
h.py, line 98, in call_object
(Object: cascade2)
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/OFS/DTMLMethod.py
, line 150, in __call__
(Object: cascade2)
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/OFS/DTMLMethod.py
, line 145, in __call__
(Object: cascade2)
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/DocumentTemplate/
DT_String.py, line 502, in __call__
(Object: cascade2)
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/DocumentTemplate/
DT_In.py, line 689, in renderwob
(Object: Actors.SQL.get_children(parent=child))
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/OFS/DTMLMethod.py
, line 140, in __call__
(Object: show_html)
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/DocumentTemplate/
DT_String.py, line 502, in __call__
(Object: show_html)
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/DocumentTemplate/
DT_In.py, line 689, in renderwob
(Object: Actors.SQL.get_entry(tag_id=child))
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/DocumentTemplate/
DT_Util.py, line 315, in eval
(Object: make_html(content, src, thetag, level, tagclass, header))
File <string>, line 0, in ?
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/Products/External
Method/ExternalMethod.py, line 259, in __call__
(Object: make_html)
(Info: ((A.M.McDonald', None, 'topic', None, 'modulecontributor',
None), {}, None))
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/Products/External
Method/ExternalMethod.py, line 254, in __call__
(Object: make_html)
(Info: (('P.M.Bradley', None, 'topic', None, 'modulecontributor',
None), {}, None))
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/Extensions/make_html3.py,
line 19, in make_html
(Object: ElementWithAttributes)
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/OFS/DTMLDocument.
py, line 162, in __call__
(Object: modulecontributor)
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/DocumentTemplate/
DT_String.py, line 502, in __call__
(Object: modulecontributor)
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/DocumentTemplate/
DT_In.py, line 631, in renderwob
(Object: info_from_email(email=content))
File
/home/nnle/Zope-2.0.0b1-solaris-2.6-sparc/lib/python/DocumentTemplate/
DT_Util.py, line 315, in eval
(Object: info_from_email(email=content))
File <string>, line 0, in ?
NameError: (see above)
-->
I reduced things down until the <dtml-in> was looping over a token
property. Still no joy.
Any ideas?
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