[Checkins] SVN: megrok.layout/trunk/ svn merge -r 122121:122162 svn+ssh://svn.zope.org/repos/main/megrok.layout/branches/jj-errorviews .
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Wed Jul 13 04:40:39 EDT 2011
Log message for revision 122164:
svn merge -r 122121:122162 svn+ssh://svn.zope.org/repos/main/megrok.layout/branches/jj-errorviews .
Changed:
_U megrok.layout/trunk/
D megrok.layout/trunk/CHANGES.TXT
A megrok.layout/trunk/CHANGES.txt
U megrok.layout/trunk/setup.py
U megrok.layout/trunk/src/megrok/layout/README.txt
U megrok.layout/trunk/src/megrok/layout/__init__.py
U megrok.layout/trunk/src/megrok/layout/components.py
U megrok.layout/trunk/src/megrok/layout/tests/ftesting.zcml
A megrok.layout/trunk/src/megrok/layout/tests/models/errorviews.py
-=-
Property changes on: megrok.layout/trunk
___________________________________________________________________
Modified: svn:ignore
- develop-eggs
bin
parts
.installed.cfg
+ develop-eggs
bin
parts
.installed.cfg
coverage
Deleted: megrok.layout/trunk/CHANGES.TXT
===================================================================
--- megrok.layout/trunk/CHANGES.TXT 2011-07-13 08:35:53 UTC (rev 122163)
+++ megrok.layout/trunk/CHANGES.TXT 2011-07-13 08:40:38 UTC (rev 122164)
@@ -1,116 +0,0 @@
-Changelog
-=========
-
-1.4 (unreleased)
-----------------
-
-- Fixed default template for megrok.layout.Form component.
-
-1.3 (2011-01-12)
-----------------
-
-- Compatibility with grokcore.view 2.3.
-
-1.2.0 (2010-12-16)
-------------------
-
-- Update to use the new TemplateGrokker from grokcore.view.
-
-1.1.0 (2010-03-03)
-------------------
-
-- ``z3c.flashmessage`` has been dropped in favor of
- ``grokcore.message``. This new package takes in charge the
- registration of the utilities and retains the existing API. The
- back-compatibility is assured.
-
-1.0.2 (2010-02-26)
-------------------
-
-- The existence test for the `application_url` site-lookup was
- wrongly using a "if not" statement. In a case of a container, the object
- is evaluated to False if it's empty. We now use a proper "if .. is
- None". [trollfot]
-
-1.0.1 (2010-02-25)
-------------------
-
-- Forms now inherit from `UtilityView` and therefore get the
- `application_url` and `flash` methods. Tests have been added to
- garanty the behavior. [trollfot]
-
-1.0 (2010-02-25)
-----------------
-
-- The dependencies have been heavily cleaned up. All zope.app packages
- have been removed. We are now running with minimal dependencies and
- using the latest ZTK. This release will probably *not* run on
- `Grok 1.0`. You will need `Grok 1.1rc1` to be able to use
- it. [trollfot]
-
-- Added a component called UtilityView that provides two useful
- methods : application_url, flash. These methods are almost a copy of
- what can be found in the `Grok` package. The application_url is
- using a simple getSite hook to get the root of the application. This
- might be irrelevant for some applications and can be overriden.
- [trollfot]
-
-- Added a module called 'messages' that contains the flash messages
- utilities. This module is *NOT* grokked and must be grokked
- manually. This prevents conflicts with grokui.admin's own
- definitions of the very same components. It also allows you to
- override the `flash` method to use something else than
- z3c.flashmessage and then not be bothered by useless utilities. The
- flash messages utilities can be registered by including the
- ``messages.zcml`` file in your own project or package ZCML file.
- [trollfot]
-
-0.9 (2009-09-26)
-----------------
-
-- Add default templates to form which doesn't contain an html and body
- tag.
- [sylvain]
-
-- Add an AddForm, EditForm and DisplayForm, all aware of the layout
- component.
- [sylvain]
-
-0.8 (2009-09-17)
-----------------
-
-- Remove the CodePage, since CodeView have been removed from
- grokcore.view.
- [sylvain]
-
-0.7 (2009-09-15)
-----------------
-
-- Add a CodePage to be compatible with the last version of
- grokcore.view (higher than 1.9). This breaks compatibility with
- previous release. You need to change any Page using a render method
- to a CodePage.
- [sylvain]
-
-- The content property on a Page is no longer a property, but a method
- as it's hidding exceptions. You might need to update your code to
- reflect that change as well.
- [sylvain]
-
-- Fix MANIFEST.in.
- [sylvain]
-
-0.6 (2009-09-14)
-----------------
-
-- switch the arguments order in calling the layout
- [cklinger, sylvain]
-
-- add the CHANGES.txt
- [cklinger]
-
-0.5 (2009-07-24)
-----------------
-
-- remove the grok dependency
- [cklinger trollfot]
Copied: megrok.layout/trunk/CHANGES.txt (from rev 122163, megrok.layout/trunk/CHANGES.TXT)
===================================================================
--- megrok.layout/trunk/CHANGES.txt (rev 0)
+++ megrok.layout/trunk/CHANGES.txt 2011-07-13 08:40:38 UTC (rev 122164)
@@ -0,0 +1,116 @@
+Changelog
+=========
+
+1.4 (unreleased)
+----------------
+
+- Fixed default template for megrok.layout.Form component.
+
+1.3 (2011-01-12)
+----------------
+
+- Compatibility with grokcore.view 2.3.
+
+1.2.0 (2010-12-16)
+------------------
+
+- Update to use the new TemplateGrokker from grokcore.view.
+
+1.1.0 (2010-03-03)
+------------------
+
+- ``z3c.flashmessage`` has been dropped in favor of
+ ``grokcore.message``. This new package takes in charge the
+ registration of the utilities and retains the existing API. The
+ back-compatibility is assured.
+
+1.0.2 (2010-02-26)
+------------------
+
+- The existence test for the `application_url` site-lookup was
+ wrongly using a "if not" statement. In a case of a container, the object
+ is evaluated to False if it's empty. We now use a proper "if .. is
+ None". [trollfot]
+
+1.0.1 (2010-02-25)
+------------------
+
+- Forms now inherit from `UtilityView` and therefore get the
+ `application_url` and `flash` methods. Tests have been added to
+ garanty the behavior. [trollfot]
+
+1.0 (2010-02-25)
+----------------
+
+- The dependencies have been heavily cleaned up. All zope.app packages
+ have been removed. We are now running with minimal dependencies and
+ using the latest ZTK. This release will probably *not* run on
+ `Grok 1.0`. You will need `Grok 1.1rc1` to be able to use
+ it. [trollfot]
+
+- Added a component called UtilityView that provides two useful
+ methods : application_url, flash. These methods are almost a copy of
+ what can be found in the `Grok` package. The application_url is
+ using a simple getSite hook to get the root of the application. This
+ might be irrelevant for some applications and can be overriden.
+ [trollfot]
+
+- Added a module called 'messages' that contains the flash messages
+ utilities. This module is *NOT* grokked and must be grokked
+ manually. This prevents conflicts with grokui.admin's own
+ definitions of the very same components. It also allows you to
+ override the `flash` method to use something else than
+ z3c.flashmessage and then not be bothered by useless utilities. The
+ flash messages utilities can be registered by including the
+ ``messages.zcml`` file in your own project or package ZCML file.
+ [trollfot]
+
+0.9 (2009-09-26)
+----------------
+
+- Add default templates to form which doesn't contain an html and body
+ tag.
+ [sylvain]
+
+- Add an AddForm, EditForm and DisplayForm, all aware of the layout
+ component.
+ [sylvain]
+
+0.8 (2009-09-17)
+----------------
+
+- Remove the CodePage, since CodeView have been removed from
+ grokcore.view.
+ [sylvain]
+
+0.7 (2009-09-15)
+----------------
+
+- Add a CodePage to be compatible with the last version of
+ grokcore.view (higher than 1.9). This breaks compatibility with
+ previous release. You need to change any Page using a render method
+ to a CodePage.
+ [sylvain]
+
+- The content property on a Page is no longer a property, but a method
+ as it's hidding exceptions. You might need to update your code to
+ reflect that change as well.
+ [sylvain]
+
+- Fix MANIFEST.in.
+ [sylvain]
+
+0.6 (2009-09-14)
+----------------
+
+- switch the arguments order in calling the layout
+ [cklinger, sylvain]
+
+- add the CHANGES.txt
+ [cklinger]
+
+0.5 (2009-07-24)
+----------------
+
+- remove the grok dependency
+ [cklinger trollfot]
Modified: megrok.layout/trunk/setup.py
===================================================================
--- megrok.layout/trunk/setup.py 2011-07-13 08:35:53 UTC (rev 122163)
+++ megrok.layout/trunk/setup.py 2011-07-13 08:40:38 UTC (rev 122164)
@@ -47,7 +47,9 @@
'grokcore.view >= 2.3',
'martian',
'setuptools',
+ 'zope.authentication',
'zope.component >= 3.9.1',
+ 'zope.errorview',
'zope.interface',
'zope.publisher',
],
Modified: megrok.layout/trunk/src/megrok/layout/README.txt
===================================================================
--- megrok.layout/trunk/src/megrok/layout/README.txt 2011-07-13 08:35:53 UTC (rev 122163)
+++ megrok.layout/trunk/src/megrok/layout/README.txt 2011-07-13 08:40:38 UTC (rev 122164)
@@ -101,8 +101,9 @@
>>> page()
u'Header. Page: Looks like an elephant. Footer'
-Forms
-=====
+Forms & Errorpages
+==================
-You have as well a Form, AddForm, EditForm and DisplayForm availables,
-which are all aware of Layout components like Page does.
+Baseclasses for Form views (Form, AddForm, EditForm and DisplayForm) and Error
+views (NotFoundView, ExceptionView, UnauthorizedView) are available which are
+all aware of Layout components like Page is.
Modified: megrok.layout/trunk/src/megrok/layout/__init__.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/__init__.py 2011-07-13 08:35:53 UTC (rev 122163)
+++ megrok.layout/trunk/src/megrok/layout/__init__.py 2011-07-13 08:40:38 UTC (rev 122164)
@@ -3,3 +3,5 @@
from megrok.layout.interfaces import ILayout, IPage
from megrok.layout.components import Layout, Page, Form
from megrok.layout.components import AddForm, EditForm, DisplayForm
+from megrok.layout.components import UnauthorizedView, NotFoundView
+from megrok.layout.components import ExceptionView
Modified: megrok.layout/trunk/src/megrok/layout/components.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/components.py 2011-07-13 08:35:53 UTC (rev 122163)
+++ megrok.layout/trunk/src/megrok/layout/components.py 2011-07-13 08:40:38 UTC (rev 122164)
@@ -8,7 +8,11 @@
from megrok.layout.interfaces import IPage, ILayout
from zope.interface import Interface
+import zope.publisher.interfaces
+import zope.security.interfaces
from zope.publisher.publish import mapply
+import zope.interface.common.interfaces
+import zope.errorview.browser
from zope.component.hooks import getSite
@@ -184,3 +188,29 @@
"""
grok.baseclass()
template = default_display_template
+
+
+class ExceptionView(zope.errorview.browser.ExceptionView, Page):
+ grok.context(zope.interface.common.interfaces.IException)
+ grok.baseclass()
+
+ def __call__(self):
+ # Make sure the __call__ handling of the Page component is
+ # used, not that of any of the bases in the ExceptionView class
+ # hierarchy.
+ return Page.__call__(self)
+
+class NotFoundView(zope.errorview.browser.NotFoundView, Page):
+ grok.context(zope.publisher.interfaces.INotFound)
+ grok.baseclass()
+
+ def __call__(self):
+ return Page.__call__(self)
+
+
+class UnauthorizedView(zope.errorview.browser.UnauthorizedView, Page):
+ grok.context(zope.security.interfaces.IUnauthorized)
+ grok.baseclass()
+
+ def __call__(self):
+ return Page.__call__(self)
Modified: megrok.layout/trunk/src/megrok/layout/tests/ftesting.zcml
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/ftesting.zcml 2011-07-13 08:35:53 UTC (rev 122163)
+++ megrok.layout/trunk/src/megrok/layout/tests/ftesting.zcml 2011-07-13 08:40:38 UTC (rev 122164)
@@ -12,6 +12,9 @@
<grok:grok package=".layout" />
<grok:grok package=".models" />
+ <!-- In order to test the errorviews that stem from zope.errorview. -->
+ <include package="zope.errorview.tests" file="ftesting.zcml"/>
+
<!-- We do not grok the other packages on purpose -->
</configure>
Copied: megrok.layout/trunk/src/megrok/layout/tests/models/errorviews.py (from rev 122162, megrok.layout/branches/jj-errorviews/src/megrok/layout/tests/models/errorviews.py)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/models/errorviews.py (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/models/errorviews.py 2011-07-13 08:40:38 UTC (rev 122164)
@@ -0,0 +1,63 @@
+"""
+ >>> from zope.component import getMultiAdapter
+ >>> from zope.publisher.browser import TestRequest
+ >>> view = getMultiAdapter((Exception(), TestRequest()), name='index')
+ >>> import megrok.layout
+ >>> isinstance(view, megrok.layout.ExceptionView)
+ True
+ >>> print view.render()
+ A system error occurred.
+ >>> print view()
+ <html>
+ <body>
+ <div class="layout">A system error occurred.</div>
+ </body>
+ </html>
+
+ >>> from zope.security.interfaces import Unauthorized
+ >>> class MockPrincipal(object):
+ ... id = 'mock principal'
+ >>> request = TestRequest()
+ >>> request.setPrincipal(MockPrincipal())
+ >>> errorpage = getMultiAdapter((Unauthorized(), request), name='index')
+ >>> print errorpage()
+ <html>
+ <body>
+ <div class="layout">Access to the requested resource is forbidden.</div>
+ </body>
+ </html>
+
+ >>> from zope.publisher.interfaces import NotFound
+ >>> request = TestRequest()
+ >>> errorpage = getMultiAdapter(
+ ... (NotFound(None, request), request), name='index')
+ >>> print errorpage()
+ <html>
+ <body>
+ <div class="layout">The requested resource can not be found.</div>
+ </body>
+ </html>
+
+"""
+import grokcore.component as grok
+
+from grokcore.view import templatedir
+from megrok.layout import Layout, ExceptionView, NotFoundView, UnauthorizedView
+
+
+templatedir('templates')
+
+
+class Master(Layout):
+ grok.name('master')
+ grok.context(Exception)
+
+
+class MyExceptionView(ExceptionView):
+ grok.name('index')
+
+class MyUnauthorizedView(UnauthorizedView):
+ grok.name('index')
+
+class MyNotFoundView(NotFoundView):
+ grok.name('index')
More information about the checkins
mailing list