Re: [Zope-dev] access to ZCatalog-data via xmlrpc
On Thursday 30 May 2002 11:29 am, Toby Dickenson wrote: > Yes, that means you unmarshall some xml-rpc data into a python None. Argh. That means you *cant* unmarshall some xml-rpc data into a python None. ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] access to ZCatalog-data via xmlrpc
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) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] access to ZCatalog-data via xmlrpc
Joachim Schmitz wrote: > > > --On Mittwoch, Mai 29, 2002 16:15:44 +0100 Toby Dickenson > <[EMAIL PROTECTED]> 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 >>> >>> >> '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: > > > objects"> > > I changed Zope xmlrpclib.py and added to the Marshaller class: > >def dump_None(self, value): >self.write("None\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. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH __ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ Meet us at EuroPython 2002: http://www.europython.org/ ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] access to ZCatalog-data via xmlrpc
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. ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] access to ZCatalog-data via xmlrpc
--On Mittwoch, Mai 29, 2002 16:15:44 +0100 Toby Dickenson <[EMAIL PROTECTED]> 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 >> >> > '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: objects"> I changed Zope xmlrpclib.py and added to the Marshaller class: def dump_None(self, value): self.write("None\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/ ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] access to ZCatalog-data via xmlrpc
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 > > > 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 ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )