[Checkins] SVN: z3c.jsonrpc/trunk/ Move error views to a own
configuration file
Roger Ineichen
roger at projekt01.ch
Fri Jun 13 20:07:35 EDT 2008
Log message for revision 87381:
Move error views to a own configuration file
Started error view implementation
Update CHANGES.txt
TODO:
check error handling like defined in JSON-RPC 2.0 specification
Changed:
U z3c.jsonrpc/trunk/CHANGES.txt
U z3c.jsonrpc/trunk/src/z3c/jsonrpc/configure.zcml
A z3c.jsonrpc/trunk/src/z3c/jsonrpc/error.py
A z3c.jsonrpc/trunk/src/z3c/jsonrpc/error.zcml
-=-
Modified: z3c.jsonrpc/trunk/CHANGES.txt
===================================================================
--- z3c.jsonrpc/trunk/CHANGES.txt 2008-06-14 00:04:45 UTC (rev 87380)
+++ z3c.jsonrpc/trunk/CHANGES.txt 2008-06-14 00:07:35 UTC (rev 87381)
@@ -5,6 +5,8 @@
0.5.2 (unreleased)
------------------
+- Make progress with JSON-RPC 2.0 sepcification implementation
+
- Removed unused dependency to z3c.layer in test setup
Modified: z3c.jsonrpc/trunk/src/z3c/jsonrpc/configure.zcml
===================================================================
--- z3c.jsonrpc/trunk/src/z3c/jsonrpc/configure.zcml 2008-06-14 00:04:45 UTC (rev 87380)
+++ z3c.jsonrpc/trunk/src/z3c/jsonrpc/configure.zcml 2008-06-14 00:07:35 UTC (rev 87381)
@@ -60,11 +60,6 @@
/>
- <!-- error handling -->
- <defaultView
- for="zope.interface.common.interfaces.IException"
- type=".layer.IJSONRPCLayer"
- name="error"
- />
+ <include file="error.zcml" />
</configure>
Added: z3c.jsonrpc/trunk/src/z3c/jsonrpc/error.py
===================================================================
--- z3c.jsonrpc/trunk/src/z3c/jsonrpc/error.py (rev 0)
+++ z3c.jsonrpc/trunk/src/z3c/jsonrpc/error.py 2008-06-14 00:07:35 UTC (rev 87381)
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id:$
+"""
+
+import zope.component
+import zope.i18n
+from zope.publisher.interfaces import NotFound
+from z3c.jsonrpc.interfaces import IMethodPublisher
+
+
+class UnauthorizedResponse(object):
+ """Knows how to return error content."""
+
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def __call__(self):
+ errMsg = _('You are not allowed to access this content.')
+ return zope.i18n.translate(errMsg, context=self.request)
Property changes on: z3c.jsonrpc/trunk/src/z3c/jsonrpc/error.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.jsonrpc/trunk/src/z3c/jsonrpc/error.zcml
===================================================================
--- z3c.jsonrpc/trunk/src/z3c/jsonrpc/error.zcml (rev 0)
+++ z3c.jsonrpc/trunk/src/z3c/jsonrpc/error.zcml 2008-06-14 00:07:35 UTC (rev 87381)
@@ -0,0 +1,51 @@
+<configure
+ xmlns:zope="http://namespaces.zope.org/zope"
+ xmlns="http://namespaces.zope.org/browser"
+ i18n_domain="zope">
+
+ <!-- implement error views for this exceptions
+ The error views should return a 1i8n aware error message as result
+ which get set in setResult instead of using the built in
+ handleException form the JSONRPCResponse.
+ See zope.app.publication.zopepublication.ZopePublication
+ -->
+ <defaultView
+ name="error"
+ for="zope.interface.common.interfaces.IException"
+ layer="z3c.jsonrpc.layer.IJSONRPCLayer"
+ />
+
+ <defaultView
+ name="error"
+ for="zope.publisher.interfaces.ITraversalException"
+ layer="z3c.jsonrpc.layer.IJSONRPCLayer"
+ />
+
+ <!-- IUnauthorized -->
+ <page
+ name="error"
+ class=".error.UnauthorizedResponse"
+ for="zope.security.interfaces.IUnauthorized"
+ layer="z3c.jsonrpc.layer.IJSONRPCLayer"
+ permission="zope.Public"
+ />
+
+ <defaultView
+ name="error"
+ for="zope.security.interfaces.IUnauthorized"
+ layer="z3c.jsonrpc.layer.IJSONRPCLayer"
+ />
+
+ <defaultView
+ name="error"
+ for="zope.exceptions.interfaces.IUserError"
+ layer="z3c.jsonrpc.layer.IJSONRPCLayer"
+ />
+
+ <defaultView
+ name="error"
+ for="zope.publisher.interfaces.INotFound"
+ layer="z3c.jsonrpc.layer.IJSONRPCLayer"
+ />
+
+</configure>
Property changes on: z3c.jsonrpc/trunk/src/z3c/jsonrpc/error.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list