Hi,
I want to acces a ZCatalog via xmlrpc, but
server=xmlrpclib.Server("http://myserver.aixtraware.de" ,BasicAuthTransport(username="user",password="pw")) r = server.Catalog()
results in
<Fault -1: "Unexpected Zope exception: cannot marshal <type 'IOBTreeItems'> objects">
What is to do, to enable marshalling of those types ?
Mit freundlichen Grüßen Joachim Schmitz -------------------------------------------------------------------- AixtraWare Ingenieurbüro für Internetanwendungen Hüsgenstr. 33a, D-52457 Aldenhoven Telefon: +49-2464-8851, FAX: +49-2464-905163 -------------------------------------------------------------------- Key fingerprint = DA10 CC82 62F8 1DBB 39A1 1EDC 725B 3317 A8D7 C3A6 Keyserver: http://www.keyserver.net/en/
On Wednesday 29 May 2002 3:24 pm, Joachim Schmitz wrote:
Hi,
I want to acces a ZCatalog via xmlrpc, but
server=xmlrpclib.Server("http://myserver.aixtraware.de" ,BasicAuthTransport(username="user",password="pw")) r = server.Catalog()
results in
<Fault -1: "Unexpected Zope exception: cannot marshal <type 'IOBTreeItems'> objects">
What is to do, to enable marshalling of those types ?
You could hack xmlrpclib to marshall those object, but I dont recommend it. Those objects can be big (but lazily evaluated), and you would be opening a significant denial of service vulnerability in your server.
I suggest you create a method (Python Script?) that makes the catalog query, sanitizes the response by making sure it is not too big, and returns a vanilla list or dictionary
--On Mittwoch, Mai 29, 2002 16:15:44 +0100 Toby Dickenson tdickenson@geminidataloggers.com wrote:
On Wednesday 29 May 2002 3:24 pm, Joachim Schmitz wrote:
Hi,
I want to acces a ZCatalog via xmlrpc, but
server=xmlrpclib.Server("http://myserver.aixtraware.de" ,BasicAuthTransport(username="user",password="pw ")) r = server.Catalog()
results in
<Fault -1: "Unexpected Zope exception: cannot marshal <type 'IOBTreeItems'> objects">
What is to do, to enable marshalling of those types ?
You could hack xmlrpclib to marshall those object, but I dont recommend it. Those objects can be big (but lazily evaluated), and you would be opening a significant denial of service vulnerability in your server.
But it also can be very interesting for exporting data from a Zope site, to be used in other applications.
I suggest you create a method (Python Script?) that makes the catalog query, sanitizes the response by making sure it is not too big, and returns a vanilla list or dictionary
I wrote a little pythonscript to export data from a ZPatterns Rack, where the data is stored in a propertysheet:
res=context.Catalog()
t=[] for m in sequence.sort(res,(('reg_id','cmp','desc'),)): r=m.propertysheets.Basic.propertyItems() t.append(r) return t
This runs fine, when I test the script. But when I access it with xmlrpc, I get:
<Fault -1: "Unexpected Zope exception: cannot marshal <type 'None'> objects">
I changed Zope xmlrpclib.py and added to the Marshaller class:
def dump_None(self, value): self.write("<value><string>None</string></value>\n") dispatch[NoneType] = dump_None
Now that works, but I think the xmlrpclib.py, should be able to marshall the "None" type.
Mit freundlichen Grüßen Joachim Schmitz -------------------------------------------------------------------- AixtraWare Ingenieurbüro für Internetanwendungen Hüsgenstr. 33a, D-52457 Aldenhoven Telefon: +49-2464-8851, FAX: +49-2464-905163 -------------------------------------------------------------------- Key fingerprint = DA10 CC82 62F8 1DBB 39A1 1EDC 725B 3317 A8D7 C3A6 Keyserver: http://www.keyserver.net/en/
On Thursday 30 May 2002 10:35 am, Joachim Schmitz wrote:
You could hack xmlrpclib to marshall those object, but I dont recommend it. Those objects can be big (but lazily evaluated), and you would be opening a significant denial of service vulnerability in your server.
But it also can be very interesting for exporting data from a Zope site, to be used in other applications.
Sure, but you dont want to to marshall your whole zope site into one huge in-memory string.
Now that works, but I think the xmlrpclib.py, should be able to marshall the "None" type.
Yes. updating xmlrpclib.py is on the todo list for zope 2.6. I hope a change similar to this will be included.
Joachim Schmitz wrote:
--On Mittwoch, Mai 29, 2002 16:15:44 +0100 Toby Dickenson tdickenson@geminidataloggers.com wrote:
On Wednesday 29 May 2002 3:24 pm, Joachim Schmitz wrote:
Hi,
I want to acces a ZCatalog via xmlrpc, but
server=xmlrpclib.Server("http://myserver.aixtraware.de" ,BasicAuthTransport(username="user",password="pw ")) r = server.Catalog()
results in
<Fault -1: "Unexpected Zope exception: cannot marshal <type 'IOBTreeItems'> objects">
What is to do, to enable marshalling of those types ?
XML-RPC only has a limited set of types it can marshal and that can't be changed without breaking the standard.
The alternative would be sending Python pickles encoded as XML-RPC binary over the wire.
You could hack xmlrpclib to marshall those object, but I dont recommend it. Those objects can be big (but lazily evaluated), and you would be opening a significant denial of service vulnerability in your server.
But it also can be very interesting for exporting data from a Zope site, to be used in other applications.
I suggest you create a method (Python Script?) that makes the catalog query, sanitizes the response by making sure it is not too big, and returns a vanilla list or dictionary
I wrote a little pythonscript to export data from a ZPatterns Rack, where the data is stored in a propertysheet:
res=context.Catalog()
t=[] for m in sequence.sort(res,(('reg_id','cmp','desc'),)): r=m.propertysheets.Basic.propertyItems() t.append(r) return t
This runs fine, when I test the script. But when I access it with xmlrpc, I get:
<Fault -1: "Unexpected Zope exception: cannot marshal <type 'None'> objects">
I changed Zope xmlrpclib.py and added to the Marshaller class:
def dump_None(self, value): self.write("<value><string>None</string></value>\n") dispatch[NoneType] = dump_None
Now that works, but I think the xmlrpclib.py, should be able to marshall the "None" type.
None doesn't have an equivalent type in XML-RPC.
On Thursday 30 May 2002 11:11 am, M.-A. Lemburg wrote:
XML-RPC only has a limited set of types it can marshal and that can't be changed without breaking the standard.
Yes, that means you unmarshall some xml-rpc data into a python None.
xmlrpc doesnt have support for marshalling class instances, but xmlrpclib.py will marshall python class instances to xmlrpc dictionaries *because* *it* *is* *useful* to do so.
If you were designing an interface specifically for xml-rpc you would design it to avoid Nones. However most Zope interfaces are designed for other purposes, then xml-rpc usage comes later. Its difficult to take the None's out of your data structures once they are in.
When the xml-rpc marshaller sees a None going *out* of Zope, I think it makes sense to marshall this is an integer zero (or Joachim suggested the string "None"). That makes more sense than raising an exception. (In Zope, anyway. Im not making any comments about other xmlrpclib.py uses)