Zope3的极简层设置
项目描述
此包为Zope3提供了一个极简层设置。
适用于Zope 3的极简浏览器层
此包包含最小层。此层支持正确的组件注册集合,并可用于自定义皮肤的继承。
目前Zope3的默认实现中,遍历概念和默认层的注册有所不同。
IMinimalBrowserLayer 接口
最小层对于构建自定义呈现皮肤非常有用,而无需访问ZMI菜单(如“zmi_views”等)。这意味着如果您使用此层,则不会注册任何菜单项。
此层不是从IDefaultBrowserLayer派生的。因此,它仅提供最基本的重要公共视图集合,如@@absolute_url。以下包被计入:
zope.app.http.exception
zope.app.publication
zope.app.publisher.browser
zope.app.traversing
zope.app.traversing.browser
测试
为了测试IMinimalBrowserLayer层,我们使用了测试包中定义的测试皮肤,该皮肤使用IMinimalBrowserLayer层作为唯一的基本层。这意味着,我们的测试皮肤仅提供最小包中定义的视图以及测试中定义的测试视图。
首先登录为管理员
>>> from zope.testbrowser.testing import Browser >>> manager = Browser() >>> manager.addHeader('Authorization', 'Basic mgr:mgrpw')
检查我们是否可以访问在ftesting.zcml文件中注册的page.html视图
>>> manager = Browser() >>> manager.addHeader('Authorization', 'Basic mgr:mgrpw') >>> skinURL = 'https://127.0.0.1/++skin++MinimalTesting' >>> manager.open(skinURL + '/page.html') >>> manager.url 'https://127.0.0.1/++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>
变更日志
1.2.1 (2009-06-19)
删除zpkg的zcml slug文件和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。
确保long_description在pypi上正确渲染。
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正常化器,代码现在可以在mechanize修复或未修复的情况下工作。
0.2.2 (2007-10-31)
错误:修复了包元数据。
错误:修复了由于依赖项更新导致的测试失败。
重构:修复了关于ZopeSecurityPolicy的弃用警告。
0.2.1 (2007-??-??)
更改未知。
0.2.0 (2007-??-??)
初始发布。
z3c.layer.minimal-1.2.1.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 45ddcf8994c0c6f776f5d6b6e3436d7a0ba80231f2ce915c84e99e066248488c |
|
MD5 | 54315951c90d7e8ccf7f4b6c17ecfdc0 |
|
BLAKE2b-256 | 361ee35138406a69247c03ca74445e16b3d5ff5a301e6d2f21a284606124d5d7 |