source: main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/browser/exceptions.py @ 12696

Last change on this file since 12696 was 11954, checked in by Henrik Bettermann, 10 years ago

Remove tools.

rename institution company.

Remove some apis from docs.

  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1## $Id: exceptions.py 11954 2014-11-13 16:54:17Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18import grok
19import zope.errorview.browser
20from zope.interface.common.interfaces import IException
21from zope.errorview.http import SystemErrorViewMixin
22from zope.publisher.interfaces import INotFound
23from zope.security.interfaces import IUnauthorized
24from waeup.ikoba.browser.layout import IkobaPage
25
26grok.templatedir('templates')
27
28class ExceptionView(grok.View, zope.errorview.browser.ExceptionView,
29                    SystemErrorViewMixin):
30    """Base class for rendering views for uncaught exceptions that occur during
31    the application run-time and are not otherwise rendered.
32
33    Backport from Grok 1.6.
34
35    XXX: This view is shared for all apps and objects in the ZODB root.
36    """
37    grok.context(IException)
38    grok.name('index.html')
39    grok.template('exception')
40
41    def update(self):
42        return zope.errorview.browser.ExceptionView.update(self)
43
44class UnauthorizedView(grok.View, zope.errorview.browser.UnauthorizedView):
45    """Base class for rendering views for IUnauthorized exceptions.
46
47    Backport from grok 1.6. This is only a view (not a page) because
48    we cannot trust that the associated :exc:`Unauthorized` exceptions
49    happened inside a w.k. site.
50
51    If not, then we have no layout available at time of rendering.
52
53    XXX: This view is shared for all apps and objects in the ZODB root.
54    """
55    grok.context(IUnauthorized)
56    grok.name('index.html')
57    grok.template('unauthorized')
58
59    def update(self):
60        return zope.errorview.browser.UnauthorizedView.update(self)
61
62
63class NotFoundPage(IkobaPage):
64    """A page rendered when an object cannot be found.
65
66    XXX: This page won't work for objects above a w.k.Company.
67    """
68    grok.context(INotFound)
69    grok.name('index.html')
70    grok.template('notfound')
71
72    title = u'404: File Not Found'
73
74    def update(self):
75        try:
76            self.context = grok.getSite()
77        except:
78            pass
79        self.response.setStatus(404)
80        return
Note: See TracBrowser for help on using the repository browser.