Am 14.12.2007 um 01:29 schrieb Jeremy Roberts:
Hello zope3 users!

I'm using Zope-3.3.1, and I'm trying to expose a method via xmlrpc and I'm having trouble supporting a variable number of kwargs. My use case does not know ahead of time how many arguments will be passed to the method, hence the use of **kwargs in the method signature.

I get the error:
Unexpected Zope exception: TypeError: renderCode() takes at most 1 argument (2 given).


I think this is because XML-RPC does not support (optional) keyword arguments, you only may use positional arguments. A solution for optional arguments can be a dictionary containing the optional arguments for your XML-RPC-View as the last parameter. But this parameter is not optional itself.

So your view could look like:

class ToolCodeXMLRPC(MethodPublisher):
   """An XMLRPC view for ToolCode objects."""

   def renderCode(self, data):
       return self.context.renderCode(**data)

Yours sincerely,
Michael Howitz

gocept gmbh & co. kg · forsterstrasse 29 · 06112 halle/saale · fon: +49 345 12298898 · fax: +49 345 12298891

Zope3-users mailing list

Reply via email to