Zope3的最小层设置
z3c.layer.minimal的Python项目详细描述
这个包为zope3提供了一个最小的层设置。
内容
Minimal Browser Layer for Zope 3
这个包包含最小层。此层支持一组正确的 组件注册,可用于自定义外观中的继承。
现在zope3中的默认实现在 遍历概念,用于默认层上的多个注册。
^{tt1}$ Interface
最小层对于构建没有访问权限的自定义表示皮肤非常有用
对于zmi菜单,如zmi_views
等,这意味着没有注册菜单项
如果你用这个图层。
此层不是从IDefaultBrowserLayer派生的。因此它提供 只有极少数最重要的公众观点,如 @@absolute_url。计算以下包:
- zope.app.http.exception
- zope.app.publication
- zope.app.publisher.browser
- zope.app.traversing
- zope.app.traversing.browser
Testing
为了测试IMinimalBrowserLayer层,我们使用定义的测试皮肤 在使用IMinimalBrowserLayer层作为唯一 基层。这意味着,我们的测试皮肤只提供定义的视图 在最小包中,它的测试视图在测试中定义。
首先以管理员身份登录:
>>> from zope.testbrowser.testing import Browser >>> manager = Browser() >>> manager.addHeader('Authorization', 'Basic mgr:mgrpw')
检查我们是否可以访问在 ftesting.zcml皮肤文件:
>>> manager = Browser() >>> manager.addHeader('Authorization', 'Basic mgr:mgrpw') >>> skinURL = 'http://localhost/++skin++MinimalTesting' >>> manager.open(skinURL + '/page.html') >>> manager.url 'http://localhost/++skin++MinimalTesting/page.html'>>> print manager.contents <BLANKLINE> <html> <head> <title>testing</title> </head> <body> <BLANKLINE> test page <BLANKLINE> </body> </html> <BLANKLINE> <BLANKLINE>
现在检查“未找到”页,该页是异常上的异常视图 zope.publisher.interfaces.INotFound:
>>> manager.open(skinURL + '/foobar.html') Traceback (most recent call last): ... HTTPError: HTTP Error 404: Not Found>>> print manager.contents <BLANKLINE> <html> <head> <title>testing</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> </body> </html> <BLANKLINE> <BLANKLINE>
并检查用户错误页,该页是为 zope.exceptions.interfaces.IUserError异常:
>>> manager.open(skinURL + '/@@usererror.html') >>> print manager.contents <BLANKLINE> <html> <head> <title>testing</title> </head> <body> <div> <div>simply user error</div> </div> </body> </html> <BLANKLINE> <BLANKLINE>
并检查注册的错误视图 zope.interface.common.interfaces.IException:
>>> manager.open(skinURL + '/@@systemerror.html') >>> print manager.contents <BLANKLINE> <html> <head> <title>testing</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> </body> </html> <BLANKLINE> <BLANKLINE>
并检查zope.security.interfaces.IUnauthorized视图,使用新的 此项的未注册用户(测试浏览器):
>>> unauthorized = Browser() >>> unauthorized.open(skinURL + '/@@forbidden.html') Traceback (most recent call last): ... HTTPError: HTTP Error 401: Unauthorized>>> print unauthorized.contents <BLANKLINE> <html> <head> <title>testing</title> </head> <body> <div> <BLANKLINE> <h1>Unauthorized</h1> <BLANKLINE> <p>You are not authorized</p> <BLANKLINE> </div> </body> </html> <BLANKLINE> <BLANKLINE>
CHANGES
1.2.1 (2009-06-19)
- 删除zcml slug文件和zpkg的setup.cfg文件。
- 添加了对zope.app.exception缺少的依赖项。
1.2.0 (2009-02-21)
- 安全问题:为定义的遍历器 IMinimalBrowserLayer是受信任的适配器,因此安全性 代理从每个遍历对象中移除。因此所有子对象 也可以公开访问。
1.1.0 (2009-02-19)
- 修复了有关ISite的依赖警告。
- 修复了使用较新zope.testbrowser的测试。
- 使用zope.container而不是zope.app.container。
- 确保在pypi上正确呈现long_描述。
1.0.1 (2008-01-24)
- 缺陷:改进的元数据。
1.0.0 (2008-01-21)
- 重组:将z3c.layer.minimal包移动到自己的顶层 从z3c.layer打包到z3c.layer.minimal。
0.2.3 (2007-11-07)
- 转发错误:由于mechanize中的错误,testbrowser抛出 httperror_seek_wrapper而不是HTTPError错误。多亏了Re 规范化程序,无论bug是否在 机械化。
0.2.2 (2007-10-31)
- 错误:修复包元数据。
- 错误:修复了由于依赖关系更新而导致的测试失败。
- 重新构造:修复了ZopeSecurityPolicy的废弃warninf。
0.2.1 (2007-??-??)
- 更改未知。
0.2.0 (2007-??-??)
- 初次发布。