Re: [Zope] Newbie - passing a list to an External Method
Thanks again for your help Dylan. If I set the External Method parameters to (self, fileID, Lines), and call it in this manner: <dtml-let link="sping2(fileID='myPDFfile.pdf',lines=mylines)"> (sping2 being the ID of the External Method - and the external method returning the fileID that is passed in as the filename to generate) I get the following error: Error Type TypeError Error Value run() takes exactly 3 non-keyword arguments (0 given) Error Trace Traceback (most recent call last): 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 "", 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) TypeError: run() takes exactly 3 non-keyword arguments (0 given) Thanks again Ashley _________________________________________________________________ Worried what your kids see online? Protect them better with MSN 8 http://join.msn.com/?page=features/parental&pgmarket=en-gb&XAPID=186&DI=1059
On Tue, 2003-04-22 at 08:31, Ashley Lloyd wrote:
Thanks again for your help Dylan.
If I set the External Method parameters to (self, fileID, Lines)
Are you adding "self" to the parameter list of the external method object in Zope? You shouldn't be. Just make it the first parameter in the external method _code_. Don't change the external method object or the DTML code that calls it. Let's see where that gets us... Dylan PS - On a tangent, it's a really good idea to get in the habit of giving your functions specific, descriptive names (like "create_pdf()") rather than naming them after a module they import or using common terms like "run()" (a name which is used elsewhere in the language). This makes troubleshoot easier and reduces the odds that you'll accidentally encounter a namespace collision.
Hi Ashley, FWIW, External Method arguments as you're trying to use them are deeply wrapped in voodoo :-( Your best bet is to stick stuff in the REQUEST as follows: <dtml-call "REQUEST.set({'fileId':'xxx','lines':y})"> def run(self): REQUEST = self.REQUEST fileId = REQUEST.fileId lines = REQUEST.lines cheers, Chris
participants (3)
-
Ashley Lloyd -
Chris Withers -
Dylan Reinhardt