Package: z3c.layer.pagelet
This package provides a pagelet based layer setup for Zope3.ContentsPagelet-based Layer for Zope 3ImportantIPageletBrowserLayerLayerTestingNot FoundUser errorCommon exception (system error)UnauthorizedForbiddenCHANGES3.0 (2023-02-17)2.1 (2018-12-01)2.0.0 (2015-11-09)2.0.0a1 (2013-03-03)1.10.1 (2012-03-03)1.10.0 (2012-02-23)1.9.0 (2010-10-13)1.8.2 (2010-10-13)1.8.1 (2010-10-11)1.8.0 (2010-08-20)1.7.0 (2009-12-24)1.6.1 (2009-12-23)1.6.0 (2009-11-30)1.5.0 (2009-05-28)1.4.0 (2009-03-16)1.3.0 (2009-03-13)1.2.1 (2009-02-21)1.2.0 (2009-02-21)1.1.0 (2009-02-14)1.0.2 (2009-04-03)1.0.1 (2008-01-24)1.0.0 (2008-01-21)0.2.3 (2007-11-07)0.2.2 (2007-10-31)0.2.1 (2007-??-??)0.2.0 (2007-??-??)Pagelet-based Layer for Zope 3This package contains the pagelet layer. This layer supports a correct set of
component registration and can be used for inheritation in custom skins.Right now the default implementation in Zope3 has different restriction in the
traversal concept and use to much registration on the default layer.ImportantThis layer ia based on the pagelet pattern. This means every page e.g. the
error page is based on the pagelet concept.IPageletBrowserLayerLayerThe pagelet layer is useful for build custom presentation skins without access
to ZMI menus likezmi_viewsetc. This means there is no menu item
registred if you use this layer.This layer isNOTderived fromIDefaultBrowserLayerlayer. Therefore it
provides only a minimal set of the most important public views such as@@absolute_urlwhich get registered in zope packages for the IHTTPRequest
and IBrowserRequest.  Next to this views, this package will only provide error
views and traversers which are normaly regsitered in the following zope
packages:zope.app.http.exceptionzope.app.publicationzope.browserresourcezope.traversingNote, this package does not depend on all the packages described above. We only
need to depend on the same interfaces where this package will define views and
traversers for.TestingFor testing theIPageletBrowserLayerlayer we use the testing skin defined
in the tests package which uses theIPageletBrowserLayerlayer as the only
base layer.  This means, that our testing skin provides only the views defined
in the minimal package and it’s testing views defined in tests.Login as manager first:>>> from webtest.app import TestApp
>>> manager = TestApp(
...     make_wsgi_app(), extra_environ={
...         'wsgi.handleErrors': False,
...         'HTTP_AUTHORIZATION': 'Basic mgr:mgrpw'})Check if we can access thepage.htmlview which is registred in theftesting.zcmlfile with our skin:>>> skinURL = 'http://localhost/++skin++PageletTestSkin'
>>> res = manager.get(skinURL + '/page.html')
>>> res.request.url
'http://localhost/++skin++PageletTestSkin/page.html'>>> print(res.html)
<!DOCTYPE...
<html ...>
<head>
<title>PageletTestLayout</title>
</head>
<body>
  test page
<BLANKLINE>
</body>
</html>
<BLANKLINE>Not FoundNow check the not found page which is a exception view on the exceptionzope.publisher.interfaces.INotFound:>>> err_manager = TestApp(
...     make_wsgi_app(), extra_environ={
...         'HTTP_AUTHORIZATION': 'Basic mgr:mgrpw'})>>> res = err_manager.get(skinURL + '/foobar.html', status=404)>>> print(res.html)
<!DOCTYPE...
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PageletTestLayout</title>
</head>
<body>
  <div>
  <br/>
  <br/>
  <h3>
    The page you are trying to access is not available
  </h3>
  <br/>
  <b>
    Please try the following:
  </b>
  <br/>
  <ol>
    <li>
      Make sure that the Web site address is spelled correctly.
    </li>
    <li>
      <a href="javascript:history.back(1);">
        Go back and try another URL.
      </a>
    </li>
  </ol>
</div>
<BLANKLINE>
</body>
</html>
<BLANKLINE>User errorAnd check the user error page which is a view registred forzope.exceptions.interfaces.IUserErrorexceptions:>>> manager.get(skinURL + '/@@usererror.html')
Traceback (most recent call last):
...
zope.exceptions.interfaces.UserError: simply user error>>> res = err_manager.get(skinURL + '/@@usererror.html')
>>> print(res.html)
<!DOCTYPE ...
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PageletTestLayout</title>
</head>
<body>
  <div>
  <div>simply user error</div>
</div>
<BLANKLINE>
</body>
</html>
<BLANKLINE>Common exception (system error)And check error view registred forzope.interface.common.interfaces.IException, it sets the HTTP status
code to 500 if called during tests or if development mode is switched on:>>> res = manager.get(skinURL + '/@@systemerror.html')
Traceback (most recent call last):
...
Exception: simply system error>>> res = err_manager.get(skinURL + '/@@systemerror.html', status=500)
>>> print(res.html)
<!DOCTYPE...
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PageletTestLayout</title>
</head>
<body>
  <div>
  <br/>
  <br/>
  <h3>A system error occurred</h3>
  <br/>
  <b>Please contact the administrator.</b>
  <a href="javascript:history.back(1);">
    Go back and try another URL.
  </a>
</div>
<BLANKLINE>
</body>
</html>
<BLANKLINE>UnauthorizedTo check thezope.security.interfaces.IUnauthorizedview, we use a
new unregistred user (test browser). As we have defined an
unauthenticatedPrincipal in ZCML (see tests/ftesting.zcml)401 Unauthorizedis returned instead of403 Forbiddenwhich would
show up otherwise:>>> unauthorized = TestApp(make_wsgi_app())
>>> res = unauthorized.get(skinURL + '/@@forbidden.html', status=401)>>> print(res.html)
<!DOCTYPE ...
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PageletTestLayout</title>
</head>
<body>
  <div>
  <br/>
  <br/>
  <h3>Unauthorized</h3>
  <br/>
  <b>You are not authorized.</b>
</div>
</body>
</html>ForbiddenWhen an authorized user tries to access a URL where he does not have enough
permissions he gets a403 Forbidden, the displayed page contents are the
same like401 Unauthorized. When an authentication utility is registered
it might display a log-in form:>>> authorized = TestApp(
...     make_wsgi_app(), extra_environ={
...         'HTTP_AUTHORIZATION': 'Basic mgr:mgrpw'})
>>> res = authorized.get(skinURL + '/@@forbidden.html', status=403)>>> print(res.html)
<!DOCTYPE ...
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PageletTestLayout</title>
</head>
<body>
  <div>
  <br/>
  <br/>
  <h3>Unauthorized</h3>
  <br/>
  <b>You are not authorized.</b>
</div>
</body>
</html>CHANGES3.0 (2023-02-17)Add support for Python 3.8, 3.9, 3.10, 3.11.Drop support for Python 2.7, 3.4, 3.5, 3.6.2.1 (2018-12-01)Add support for Python 3.5 up to 3.7.Drop support for Python 2.6 and 3.3.Drop the ability to run the tests usingpython setup.py test.2.0.0 (2015-11-09)Standardize namespace __init__.Claim Python 3.4 support.2.0.0a1 (2013-03-03)Added support for Python 3.3.Changedzope.testbrowsertests toWebTest, sincezope.testbrowseris not yet ported.Replaced deprecatedzope.interface.implementsusage with equivalentzope.interface.implementerdecorator.Dropped support for Python 2.4 and 2.5.1.10.1 (2012-03-03)Added adapter registration forzope.browserresource.interfaces.IETaginterface to be available onIPageletBrowserLayer. This adapter is
necessary to deliver file resources.1.10.0 (2012-02-23)Sets HTTP status code to 500 on system errors but only in devmode and in
tests.1.9.0 (2010-10-13)Re-release of 1.8.1 as the changes in it require a new major release
because they brokez3c.authviewlet.1.8.2 (2010-10-13)Re-release of 1.8.0 as the changes in 1.8.1 require a new major
release because they breakz3c.authviewlet.1.8.1 (2010-10-11)Doing redirect inUnauthorizedPageletnow inupdatemethod instead
ofrenderso the layout templage does not get rendered when
redirecting.Fixed tests: Using manager account, so anonymous user does not need to get
all permissions for running tests successfully.Got rid ofzope.app.testingtest dependency by usingzope.app.wsgi.Got rid ofzope.app.authenticationtest dependency.Added a test for403 Forbidden.1.8.0 (2010-08-20)Requiringzope.loginso tests run withzope.publisher>= 3.12.1.7.0 (2009-12-24)Added i18n domains to templates, so they can be translated. (Done
usingz3c.locales.)1.6.1 (2009-12-23)Movedzope.browserresourcefrom test dependencies to install
dependencies as it is needed in the ZCML configuration.1.6.0 (2009-11-30)Changed view forzope.publisher.interfaces.ITraversalExceptionfrom
system error pagelet to not found pagelet.Moved authentication viewlets toz3c.authviewlet.Cleaned up dependencies, reflecting changes in zope packages.Cleaned up test dependencies.1.5.0 (2009-05-28)Removed dependency onzope.app.exceptionby usingzope.browser>=1.2and by implementing the exception view classes
directly instead of inheriting them (Quite nothing of the base
classes was in use here.)Removed not necessary test dependency onzope.app.twisted.Removed no longer necessary test dependency onzope.app.component.1.4.0 (2009-03-16)Removed direct dependency onzope.app.securityby using the new
packageszope.authenticationandzope.principalregistry.Removed not needed test-dependency onzope.app.zcmlfiles.Fixed namespace package declaration insetup.py.1.3.0 (2009-03-13)Implemented login and logout using pagelets resp. viewlets.Updated tests to use newzope.configurationwhich containts the
exclude directive.1.2.1 (2009-02-21)Release 1.2.0 was missing the test file for the security issue.1.2.0 (2009-02-21)Security issue:The traverser defined forIPageletBrowserLayerwas a trusted adapter, so the security
proxy got removed from each traversed object. Thus all sub-objects
were publically accessable, too.1.1.0 (2009-02-14)Bugfix: use IContentTemplate instead of IPageTemplate which avoids to get the
layout template if no IPageTemplate is registered.Usingzope.location.interfaces.ISiteinstead ofzope.app.component.interfaces.ISite.Usingzope.containerinstead ofzope.app.container.Cleaned up dependencies.1.0.2 (2009-04-03)backport release, see release dateSecurity issue:The traverser defined forIPageletBrowserLayerwas a trusted adapter, so the security
proxy got removed from each traversed object. Thus all sub-objects
were publically accessable, too.Making this change might BREAK your application!
That means if security is not well declared.Bugfix: use IContentTemplate instead of IPageTemplate which avoids to get the
layout template if no IPageTemplate is registered1.0.1 (2008-01-24)Bug: Update meta data.1.0.0 (2008-01-21)Restructure: Movez3c.layer.pageletpackage to it’s own top level
package formz3c.layertoz3c.layer.pagelet.Restructure: Removedzope.app.formsupport from pagelet layer.0.2.3 (2007-11-07)Forward-Bug: Due to a bug in mechanize, the testbrowser throwshttperror_seek_wrapperinstead ofHTTPErrorerrors. Thanks to RE
normalizers, the code will now work whether the bug is fixed or not in
mechanize.0.2.2 (2007-10-31)Bug: Fixed package meta-data.Bug: Fixed test failures due to depency updates.Restructure: Fixed deprecation warning forZopeSecurityPolicy.0.2.1 (2007-??-??)Changes unknown.0.2.0 (2007-??-??)Initial release.