[Zope-dev] access to ZCatalog-data via xmlrpc
Joachim Schmitz
js@aixtraware.de
Thu, 30 May 2002 11:35:36 +0200
--On Mittwoch, Mai 29, 2002 16:15:44 +0100 Toby Dickenson=20
<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=3Dxmlrpclib.Server("http://myserver.aixtraware.de"
>> =
,BasicAuthTransport(username=3D"user",password=3D"pw
>> "))
>> r =3D 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=20
the data is stored in a propertysheet:
res=3Dcontext.Catalog()
t=3D[]
for m in sequence.sort(res,(('reg_id','cmp','desc'),)):
r=3Dm.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'>=20
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] =3D dump_None
Now that works, but I think the xmlrpclib.py, should be able to marshall=20
the "None" type.
Mit freundlichen Gr=FC=DFen Joachim Schmitz
--------------------------------------------------------------------
AixtraWare Ingenieurb=FCro f=FCr Internetanwendungen
H=FCsgenstr. 33a, D-52457 Aldenhoven
Telefon: +49-2464-8851, FAX: +49-2464-905163
--------------------------------------------------------------------
Key fingerprint =3D DA10 CC82 62F8 1DBB 39A1 1EDC 725B 3317 A8D7 C3A6
Keyserver: http://www.keyserver.net/en/