[Zope3-checkins] SVN: Zope3/trunk/ Implemented pre marshaller for
xmlrpxlib.Binary which
Roger Ineichen
roger at projekt01.ch
Thu Mar 22 22:33:37 EDT 2007
Log message for revision 73480:
Implemented pre marshaller for xmlrpxlib.Binary which
will make sure that the response doesn't contained a
proxied binary object.
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/src/zope/publisher/configure.zcml
U Zope3/trunk/src/zope/publisher/tests/test_xmlrpc.py
U Zope3/trunk/src/zope/publisher/xmlrpc.py
U Zope3/trunk/src/zope/publisher/xmlrpc.txt
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2007-03-22 18:57:07 UTC (rev 73479)
+++ Zope3/trunk/doc/CHANGES.txt 2007-03-23 02:33:36 UTC (rev 73480)
@@ -196,6 +196,9 @@
Bug fixes
+ - Implemented pre marshaller for xmlrpxlib.Binary which will make sure
+ that the response doesn't containd a proxied binary object.
+
- zope.server.http: Connection: keep-alive wasn't sent
(http://zope.org/Collectors/Zope3-dev/714)
Modified: Zope3/trunk/src/zope/publisher/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/publisher/configure.zcml 2007-03-22 18:57:07 UTC (rev 73479)
+++ Zope3/trunk/src/zope/publisher/configure.zcml 2007-03-23 02:33:36 UTC (rev 73480)
@@ -6,9 +6,14 @@
<interface interface="zope.publisher.interfaces.browser.IBrowserSkinType" />
<interface interface="zope.publisher.interfaces.xmlrpc.IXMLRPCRequest" />
+
+ <class class="xmlrpclib.Binary">
+ <allow attributes="data encode decode" />
+ </class>
<adapter factory=".xmlrpc.ListPreMarshaller" />
<adapter factory=".xmlrpc.TuplePreMarshaller" />
+ <adapter factory=".xmlrpc.BinaryPreMarshaller" />
<adapter factory=".xmlrpc.FaultPreMarshaller" />
<adapter factory=".xmlrpc.DateTimePreMarshaller" />
<adapter factory=".xmlrpc.PythonDateTimePreMarshaller" />
Modified: Zope3/trunk/src/zope/publisher/tests/test_xmlrpc.py
===================================================================
--- Zope3/trunk/src/zope/publisher/tests/test_xmlrpc.py 2007-03-22 18:57:07 UTC (rev 73479)
+++ Zope3/trunk/src/zope/publisher/tests/test_xmlrpc.py 2007-03-23 02:33:36 UTC (rev 73480)
@@ -25,11 +25,16 @@
zope.component.testing.setUp(test)
zope.component.provideAdapter(xmlrpc.ListPreMarshaller)
zope.component.provideAdapter(xmlrpc.TuplePreMarshaller)
+ zope.component.provideAdapter(xmlrpc.BinaryPreMarshaller)
zope.component.provideAdapter(xmlrpc.FaultPreMarshaller)
zope.component.provideAdapter(xmlrpc.DateTimePreMarshaller)
zope.component.provideAdapter(xmlrpc.PythonDateTimePreMarshaller)
zope.component.provideAdapter(xmlrpc.DictPreMarshaller)
+ defineChecker(xmlrpclib.Binary,
+ Checker({'data':CheckerPublic,
+ 'decode':CheckerPublic,
+ 'encode': CheckerPublic}, {}))
defineChecker(xmlrpclib.Fault,
Checker({'faultCode':CheckerPublic,
'faultString': CheckerPublic}, {}))
Modified: Zope3/trunk/src/zope/publisher/xmlrpc.py
===================================================================
--- Zope3/trunk/src/zope/publisher/xmlrpc.py 2007-03-22 18:57:07 UTC (rev 73479)
+++ Zope3/trunk/src/zope/publisher/xmlrpc.py 2007-03-23 02:33:36 UTC (rev 73480)
@@ -191,6 +191,13 @@
class TuplePreMarshaller(ListPreMarshaller):
zope.component.adapts(tuple)
+class BinaryPreMarshaller(PreMarshallerBase):
+ """Pre-marshaller for xmlrpc.Binary"""
+ zope.component.adapts(xmlrpclib.Binary)
+
+ def __call__(self):
+ return xmlrpclib.Binary(self.data.data)
+
class FaultPreMarshaller(PreMarshallerBase):
"""Pre-marshaller for xmlrpc.Fault"""
zope.component.adapts(xmlrpclib.Fault)
Modified: Zope3/trunk/src/zope/publisher/xmlrpc.txt
===================================================================
--- Zope3/trunk/src/zope/publisher/xmlrpc.txt 2007-03-22 18:57:07 UTC (rev 73479)
+++ Zope3/trunk/src/zope/publisher/xmlrpc.txt 2007-03-23 02:33:36 UTC (rev 73480)
@@ -58,4 +58,12 @@
>>> isinstance(stripped_date, xmlrpclib.DateTime)
True
+We can also use premarshal to strip proxies off of Binary objects.
+We have to make a security declaration first though:
+ >>> import xmlrpclib
+ >>> binary = xmlrpclib.Binary('foobar')
+ >>> proxied_binary = ProxyFactory(binary)
+ >>> stripped_binary = premarshal(proxied_binary)
+ >>> type(stripped_binary) is Proxy
+ False
More information about the Zope3-Checkins
mailing list