[KSS-checkins] r36041 - in kukit/azax/branch/1.1: . browser

reebalazs at codespeak.net reebalazs at codespeak.net
Fri Dec 29 18:13:14 CET 2006


Author: reebalazs
Date: Fri Dec 29 18:13:11 2006
New Revision: 36041

Added:
   kukit/azax/branch/1.1/browser/errorresponse.pt
   kukit/azax/branch/1.1/browserview.py
Modified:
   kukit/azax/branch/1.1/configure.zcml
Log:
Undo and fox the previous two commits, the default error handler and the kss_view (browser view) is backported from the kss trunk.

Added: kukit/azax/branch/1.1/browser/errorresponse.pt
==============================================================================
--- (empty file)
+++ kukit/azax/branch/1.1/browser/errorresponse.pt	Fri Dec 29 18:13:11 2006
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<root xmlns:kukit="http://www.kukit.org/commands/1.0"
+      xmlns:tal="http://xml.zope.org/namespaces/tal"
+      xmlns:metal="http://xml.zope.org/namespaces/metal">
+<kukit:commands>
+	<kukit:command name="error">
+		<kukit:param name="type" tal:content="options/type | nothing">system</kukit:param>
+		<kukit:param name="message" tal:content="options/message">Exception: reason</kukit:param>
+	</kukit:command>
+</kukit:commands>
+</root>

Added: kukit/azax/branch/1.1/browserview.py
==============================================================================
--- (empty file)
+++ kukit/azax/branch/1.1/browserview.py	Fri Dec 29 18:13:11 2006
@@ -0,0 +1,42 @@
+# -*- coding: UTF-8 -*-
+# Copyright (c) 2006
+# Authors: KSS project contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as published
+# by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+#
+
+import cgi
+from Products.Five.browser import BrowserView
+#from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+from zope.pagetemplate.pagetemplatefile import PageTemplateFile
+
+class KssBrowserView(BrowserView):
+
+    # XML output gets rendered via a page template
+    # XXX note: barefoot rendering, use python: only after zope2.9
+    render_error = PageTemplateFile('browser/errorresponse.pt')
+
+    def attach_error(self, err_type, err_value):
+        'Attach the error payload on the response'
+        message = '%s: %s' % (err_type, err_value)
+        message = cgi.escape(message)
+        payload = self.render_error(type='system', message=message)
+        self.attach_payload(payload)
+
+    def attach_payload(self, payload, header_name='X-KSSCOMMANDS'):
+        'Attach the commands on the response'
+        # get rid of newlines
+        payload = payload.replace('\n', ' ')
+        self.request.RESPONSE.setHeader(header_name, payload)

Modified: kukit/azax/branch/1.1/configure.zcml
==============================================================================
--- kukit/azax/branch/1.1/configure.zcml	(original)
+++ kukit/azax/branch/1.1/configure.zcml	Fri Dec 29 18:13:11 2006
@@ -43,5 +43,14 @@
         factory=".commands.CommandView"
         name="render"
         />
+
+    <!-- (non-kss) browser view -->
+    <browser:page
+	for="*"
+	name="kss_view"
+        permission="zope.Public"
+        class=".browserview.KssBrowserView"
+        allowed_attributes="attach_error"
+        />
     
 </configure>


More information about the Kukit-checkins mailing list