[z3-checkins] r26670 - z3/jsonserver/branch/zope2_test
reebalazs at codespeak.net
reebalazs at codespeak.net
Tue May 2 15:55:07 CEST 2006
Author: reebalazs
Date: Tue May 2 15:55:06 2006
New Revision: 26670
Modified:
z3/jsonserver/branch/zope2_test/jsonrpc.py
Log:
Fix IJsonRequest interface providing problem earlier addressed in r26026
The problem is triggered from the traverse hook set up by Five
on traversable objects. This calls setDefaultSkin in zope and this
in effect sets the IBrowserLayer on the request but also purges
all other interfaces. Which may not be a bug from a zope3 point
of view, but it screws things in this combination
XXX Workaround. We call setDefaultSkin ourselves, so later it
does not touch the interface any more.
Modified: z3/jsonserver/branch/zope2_test/jsonrpc.py
==============================================================================
--- z3/jsonserver/branch/zope2_test/jsonrpc.py (original)
+++ z3/jsonserver/branch/zope2_test/jsonrpc.py Tue May 2 15:55:06 2006
@@ -21,10 +21,10 @@
from zLOG import LOG, INFO, DEBUG, WARNING, ERROR
from cgi import FieldStorage
import ZPublisher.HTTPResponse
-##from zope.interface import directlyProvides, directlyProvidedBy
-from zope.interface import implements
+from zope.interface import directlyProvides, directlyProvidedBy
from interfaces import IJsonRequest
from ZPublisher.HTTPRequest import HTTPRequest
+from zope.app.publication.browser import setDefaultSkin
# this is used to identify incoming requests
request_content_type = 'application/json-rpc'
@@ -200,11 +200,6 @@
# Patching processInputs of ZPublisher.HTTPRequest
# --
-class JsonRpcRequest(HTTPRequest):
- 'JSON-RPC HTTP request'
- # this is just used to force the interface on the object
- implements(IJsonRequest)
-
re_content_type= re.compile(r'charset\s*=\s*([^;]+)')
def processInputs(self, **kw):
@@ -255,10 +250,18 @@
# XXX this would be good but for some reason gets "swallowed"
# by the time we get there, so we override the class instead.
# This error first manifested in Zope2.9, it was ok. till 2.8.
- ##interfaces = directlyProvidedBy(self)
- ##interfaces += IJsonRequest
- ##directlyProvides(self, interfaces)
- self.__class__ = JsonRpcRequest
+ # The problem is triggered from the traverse hook set up by Five
+ # on traversable objects. This calls setDefaultSkin in zope and this
+ # in effect sets the IBrowserLayer on the request but also purges
+ # all other interfaces. Which may not be a bug from a zope3 point
+ # of view, but it screws things in this combination
+ # XXX Workaround. We call setDefaultSkin ourselves, so later it
+ # does not touch the interface any more.
+ setDefaultSkin(self)
+ #
+ interfaces = directlyProvidedBy(self)
+ interfaces += IJsonRequest
+ directlyProvides(self, interfaces)
#
response = Response(response, jsonID)
other['RESPONSE'] = self.response = response
More information about the z3-checkins
mailing list