Getting ZClass instances from Zope via XML-RPC ??
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 org.apache.xmlrpc.XmlRpcException: Unexpected Zope exception: cannot marshal <extension class Acquisition.ImplicitAcquirerWrapper at 00C25140> org.apache.xmlrpc.XmlRpcException: Unexpected Zope exception: cannot marshal <extension class Acquisition.Impl icitAcquirerWrapper at 00C25140> objects at org.apache.xmlrpc.XmlRpcClient$Worker.execute(Unknown Source) at org.apache.xmlrpc.XmlRpcClient.execute(Unknown Source) at TreeExpandEventDemo.init(TreeExpandEventDemo.java:49) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) It seems that it's not getting actual instances, but references to them. I don't know. I am assuming that the results array of objects above should come back as a Java hashtable, per this page: http://xml.apache.org/xmlrpc/types.html Anyone explain what's going on and how i get the ZClass instances (or Python class instances) out of Zope and into my little applet?? Thanks much! mark ------------------------------------------------------------ Sent via Marzie's Toolbox (http://www.marzie.com) ------------------------------------------------------------
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
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 )
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 )
participants (4)
-
Dieter Maurer -
Gilles Lenfant -
Mark Lilly -
marq@europa.com