Thanks for the Note. I too found that returning a collection of primitives from Python worked fine. I sent back to Java a list (i believe that's right: something like this> results[[][]] ), one of which's items was another list. These came across as vectors in Java. Cheers, mark
-----Original Message----- From: Gilles Lenfant [mailto:glenfant@bigfoot.com] Sent: Wednesday, February 13, 2002 8:34 PM To: marq@europa.com Cc: zope@zope.org Subject: Re: [Zope] Getting ZClass instances from Zope via XML-RPC ??
As Dieter says, you should convert those objects to collections/dictionaries of simple objects (string, floating, integer,booleans)
This works for me (server side):
# Name : ProxyForAZClass_py # This script exposes a ZClass object to XMLRPC client # that will read a dictionnary of properties
props = ZClassObject.propertysheets.basic.propertyItems() dprops = {} for k,v in props: if k == 'someDate': # from propertysheet # It's a DateTime object (can't be marshaled for XMLRPC) v = v.timeTime() # Make it a float dprops[k] = v return dprops
Python Client side:
s = xmlrpclib.Server(UrlOfObject) dictobj = s.ProxyForAZClass_py()
HTH
----- Original Message ----- From: "Dieter Maurer" <dieter@handshake.de> To: <marq@europa.com> Cc: <zope@zope.org> Sent: Wednesday, February 13, 2002 7:57 PM Subject: Re: [Zope] Getting ZClass instances from Zope via XML-RPC ??
marq@europa.com writes:
I am wondering how to get ZClass instances from Zope to a Java XML-RPC client.
1. I have (and please forgive the Java-like pseudocode; i'm new to Python) a product with a ZClass call Invoice (meta = "Invoice Main") class Invoice { String invoice_name int invoice_id date invoice_date }
2. I have a Python Script (named 'invoice') that goes: results=[] for object in context.Projects.objectValues('Invoice Main'): results.append(object) return results
3. When i test this script directly in Zope, i get: [<Project instance at 014A00F0>, <Project instance at 01832800>, <Project instance at 015A2D80>]
4. If i call this from my XML-RPC client, i get the following Java/Zope error:
Unexpected Zope exception: cannot marshal <extension class Acquisition.ImplicitAcquirerWrapper at 00C25140> objects The XML-RPC tries to serialize (Java terminology; its called "marshal" in Python/Corba) the instances and it unable to do it.
Probably, you must convert your instances into something more elementary to help the marshaling process.
Dieter
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )