Commit e3804f4b authored by Baiju Muthukadan's avatar Baiju Muthukadan

Change configure.zcml to not depend on zope.app.component.

Fixes: https://bugs.launchpad.net/bugs/348329
(Thanks to Gary Poster for the idea, see r98787)
parent 264bb7f6
......@@ -5,6 +5,9 @@ CHANGES
3.7.3 (unreleased)
------------------
- Change configure.zcml to not depend on zope.app.component.
Fixes: https://bugs.launchpad.net/bugs/348329
- Moved the declaration of ``IOrderedContainer.updateOrder`` to a new, basic
``IOrdered`` interface and let ``IOrderedContainer`` inherit it. This allows
easier reuse of the declaration.
......
......@@ -59,7 +59,10 @@ setup(name='zope.container',
], include_dirs=['include']),
],
extras_require=dict(
test=['zope.copypastemove']),
test=['zope.copypastemove',
'zope.app.testing',
'zope.app.component',
]),
install_requires=['setuptools',
'zope.interface',
'zope.cachedescriptors',
......
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc"
i18n_domain="zope"
>
......@@ -81,22 +79,20 @@
<allow interface=".constraints.IItemTypePrecondition" />
</class>
<view
for="zope.container.interfaces.IItemContainer"
type="zope.publisher.interfaces.browser.IBrowserRequest"
<adapter
for="zope.container.interfaces.IItemContainer
zope.publisher.interfaces.browser.IBrowserRequest"
provides="zope.publisher.interfaces.browser.IBrowserPublisher"
factory="zope.container.traversal.ItemTraverser"
permission="zope.Public"
allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
/>
<view
for="zope.container.interfaces.ISimpleReadContainer"
type="zope.publisher.interfaces.browser.IBrowserRequest"
<adapter
for="zope.container.interfaces.ISimpleReadContainer
zope.publisher.interfaces.browser.IBrowserRequest"
provides="zope.publisher.interfaces.browser.IBrowserPublisher"
factory="zope.container.traversal.ItemTraverser"
permission="zope.Public"
allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
/>
</configure>
<configure
xmlns="http://namespaces.zope.org/zope">
<include package="zope.component" file="meta.zcml"/>
<include package="zope.security" file="meta.zcml" />
<include package="zope.security" file="permissions.zcml" />
<include package="zope.container"/>
</configure>
import os
import unittest
from zope.interface import implements
import zope.component
from zope.app.testing import functional
from zope.publisher.browser import TestRequest
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.container.traversal import ItemTraverser
ContainerLayer = functional.ZCMLLayer(
os.path.join(os.path.dirname(__file__), 'ftest_zcml_dependencies.zcml'),
__name__, 'ContainerLayer', allow_teardown=True)
from zope.container.interfaces import IItemContainer
from zope.container.interfaces import ISimpleReadContainer
class ZCMLDependencies(functional.BrowserTestCase):
def test_zcml_can_load_with_only_zope_component_meta(self):
# this is just an example. It is supposed to show that the
# configure.zcml file has loaded successfully.
request = TestRequest()
class SampleItemContainer(object):
implements(IItemContainer)
sampleitemcontainer = SampleItemContainer()
res = zope.component.getMultiAdapter(
(sampleitemcontainer, request), IBrowserPublisher)
self.failUnless(isinstance(res, ItemTraverser))
self.failUnless(res.context is sampleitemcontainer)
class SampleSimpleReadContainer(object):
implements(ISimpleReadContainer)
samplesimplereadcontainer = SampleSimpleReadContainer()
res = zope.component.getMultiAdapter(
(samplesimplereadcontainer, request), IBrowserPublisher)
self.failUnless(isinstance(res, ItemTraverser))
self.failUnless(res.context is samplesimplereadcontainer)
def test_suite():
suite = unittest.TestSuite()
ZCMLDependencies.layer = ContainerLayer
suite.addTest(unittest.makeSuite(ZCMLDependencies))
return suite
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment