[Zope] Newbie - passing a list to an External Method
Ashley Lloyd
ashleylloyd@hotmail.com
Thu, 17 Apr 2003 16:01:34 +0100
I am attempting to pass a simple list of strings (say mylines=['line
1','line 2','line 3'], generated by a Python Script) into an External
Method, so calling it in a dtml-method:
<dtml-let
filename="myExternalMethod(fileID='myFileName.pdf',lines=mylines)">
This external method then uses the contents of this list, and returns a
filename.
The External Method is accepting parameters, and indeed seems to be
accepting the list - if I change the method to return lines, and print that
on screen (call dtml-var... instead of let filename=...), it prints ['line
1','line 2','line 3'].
However, on attempting to view the dtml-method, I get the following error:
Error Type: AttributeError
Error Value: __getitem__
Traceback (most recent call last):<br>
File "C:\PROGRA~1\ZopeSite\lib\python\DocumentTemplate\DT_Try.py", line
149, in render_try_except
result = render_blocks(self.section, md)
File "C:\PROGRA~1\ZopeSite\lib\python\DocumentTemplate\DT_Let.py", line
75, in render
else: d[name]=expr(md)
File "C:\PROGRA~1\ZopeSite\lib\python\DocumentTemplate\DT_Util.py", line
159, in eval
return eval(code, d)
File "<string>", line 2, in f
File
"C:\PROGRA~1\ZopeSite\lib\python\Products\ExternalMethod\ExternalMethod.py",
line 198, in __call__
try: return apply(f,args,kw)
File "C:\PROGRA~1\ZopeSite\Extensions\myExternalMethod.py", line 28, in
run
y = 20
AttributeError: __getitem__
line 28 of the External Method is:
for line in lines:
(then attempts to use the 'line')
I am running Zope 2.5.1, Win 2k, btw.
I have tried several things, but nothing seems to work. This seems to work
fine if the list is declared inside the External Method, but not if it is
passed to it. Is this a feature of Zope, or of my inability? Either way, how
can I get around it?
TIA
Ashley
_________________________________________________________________
Get Hotmail on your mobile phone http://www.msn.co.uk/mobile