Skip to content

Commit

Permalink
make the browser subpackage an optional dependency. as a result, proj…
Browse files Browse the repository at this point in the history
…ects that do not need the ZMI views to be registered, will not pull in zope.app.* packages anymore.
  • Loading branch information
janwijbrand committed Oct 18, 2010
1 parent c4c5990 commit 256df15
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 79 deletions.
22 changes: 20 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,26 @@ CHANGES
The 1.2 line (and higher) supports Zope 3.4/ZODB 3.8. The 1.1 line supports
Zope 3.3/ZODB 3.7.

1.4.6 (unreleased)
------------------
1.5 (unreleased)
----------------

- The package's ``configure.zcml`` does not include the browser subpackage's
``configure.zcml`` anymore.

This, together with ``browser`` and ``test_browser`` ``extras_require``,
decouples the browser view registrations from the main code. As a result
projects that do not need the ZMI views to be registered are not pulling in
the zope.app.* dependencies anymore.

To enable the ZMI views for your project, you will have to do two things:

* list ``zc.catalog [browser]`` as a ``install_requires``.

* have your project's ``configure.zcml`` include the ``zc.catalog.browser``
subpackage.

- Only include the browser tests whenever the dependencies for the browser
tests are available.

- Python2.7 test fix.

Expand Down
9 changes: 8 additions & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
extends =
http://download.zope.org/zopetoolkit/index/1.0c3/zopeapp-versions.cfg
http://download.zope.org/zopetoolkit/index/1.0c3/ztk-versions.cfg
parts = test
parts =
test
test_no_browser
versions = versions
develop = .

[test]
recipe = zc.recipe.testrunner
eggs = zc.catalog [test, browser, test_browser]
defaults = "--exit-with-status".split()

[test_no_browser]
recipe = zc.recipe.testrunner
eggs = zc.catalog [test]
defaults = "--exit-with-status".split()
59 changes: 34 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,40 @@ def read(*rnames):
package_dir = {'': 'src'},
namespace_packages=['zc'],
extras_require=dict(
test=['zope.app.authentication',
'zope.app.catalog',
'zope.app.server',
'zope.app.testing',
'zope.app.zcmlfiles',
'zope.intid',
'zope.keyreference',
'zope.login',
'zope.securitypolicy',
'zope.testbrowser',
'zope.testing',
]),
install_requires=['ZODB3',
'pytz',
'setuptools',
'zope.catalog',
'zope.component',
'zope.container',
'zope.i18nmessageid',
'zope.index>=3.5.1',
'zope.interface',
'zope.publisher >= 3.12',
'zope.schema',
'zope.security',
],
test=[
'zope.intid',
'zope.keyreference',
'zope.login',
'zope.securitypolicy',
'zope.testbrowser',
'zope.testing',
],
browser=[
'zope.app.form',
'zope.browsermenu',
],
test_browser=[
'zope.app.appsetup',
'zope.app.authentication',
'zope.app.catalog',
'zope.app.server',
'zope.app.testing',
'zope.app.zcmlfiles',
]),
install_requires=[
'ZODB3',
'pytz',
'setuptools',
'zope.catalog',
'zope.component',
'zope.container',
'zope.i18nmessageid',
'zope.index>=3.5.1',
'zope.interface',
'zope.publisher >= 3.12',
'zope.schema',
'zope.security',
],
include_package_data = True,
zip_safe = False,
)
4 changes: 4 additions & 0 deletions src/zc/catalog/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
>

<!-- UI for SetIndex -->
<include package="zope.app.form.browser" file="meta.zcml" />
<include package="zope.app.form.browser"/>
<include package="zope.browsermenu" file="meta.zcml" />
<include package="zope.browsermenu"/>

<addform
name="AddSetIndex"
Expand Down
14 changes: 3 additions & 11 deletions src/zc/catalog/browser/ftesting.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,16 @@
i18n_domain="zc.catalog"
>

<include
zcml:condition="installed zope.app.zcmlfiles"
package="zope.app.zcmlfiles"
/>
<include
zcml:condition="not-installed zope.app.zcmlfiles"
package="zope.app"
/>

<include package="zope.app.zcmlfiles" />
<include package="zope.app.authentication" />
<include package="zope.app.server" />
<include package="zope.keyreference" />
<include package="zope.intid" />
<include package="zope.app.catalog" />
<include package="zope.login" />
<include package="zc.catalog" />

<include package="zc.catalog" />
<include package="zc.catalog.browser" />
<subscriber handler="zc.catalog.browser.tests.initializeIntIds" />

<!-- Security -->
Expand All @@ -48,7 +41,6 @@

<grantAll role="zope.Manager" />


<unauthenticatedPrincipal id="zope.anybody" title="Unauthenticated User" />

<principal id="zope.mgr" title="Manager" login="mgr" password="mgrpw" />
Expand Down
71 changes: 36 additions & 35 deletions src/zc/catalog/browser/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,46 @@
import doctest
import os.path
import unittest

import transaction

import zope.app.appsetup.bootstrap
import zope.app.appsetup.interfaces
import zope.app.testing.functional
import zope.intid
import zope.intid.interfaces


here = os.path.dirname(os.path.realpath(__file__))

ZcCatalogLayer = zope.app.testing.functional.ZCMLLayer(
os.path.join(here, "ftesting.zcml"), __name__, "ZcCatalogLayer")


@zope.component.adapter(
zope.app.appsetup.interfaces.IDatabaseOpenedWithRootEvent)
#
def initializeIntIds(event):
db, connection, root, root_folder = (
zope.app.appsetup.bootstrap.getInformationFromEvent(event))
sm = root_folder.getSiteManager()
intids = zope.intid.IntIds()
sm["default"]["test-int-ids"] = intids
sm.registerUtility(
intids,
zope.intid.interfaces.IIntIds)
transaction.commit()
connection.close()


def test_suite():
suite = zope.app.testing.functional.FunctionalDocFileSuite(
"README.txt",
optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE)
suite.layer = ZcCatalogLayer
return suite

try:
# Only include the functional tests whenever the required dependencies
# are installed.
import zope.app.appsetup.bootstrap
import zope.app.appsetup.interfaces
import zope.app.testing.functional

here = os.path.dirname(os.path.realpath(__file__))

ZcCatalogLayer = zope.app.testing.functional.ZCMLLayer(
os.path.join(here, "ftesting.zcml"), __name__, "ZcCatalogLayer")

@zope.component.adapter(
zope.app.appsetup.interfaces.IDatabaseOpenedWithRootEvent)
def initializeIntIds(event):
db, connection, root, root_folder = (
zope.app.appsetup.bootstrap.getInformationFromEvent(event))
sm = root_folder.getSiteManager()
intids = zope.intid.IntIds()
sm["default"]["test-int-ids"] = intids
sm.registerUtility(
intids,
zope.intid.interfaces.IIntIds)
transaction.commit()
connection.close()

def test_suite():
suite = zope.app.testing.functional.FunctionalDocFileSuite(
"README.txt",
optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE)
suite.layer = ZcCatalogLayer
return suite

except (ImportError,), e:
def test_suite():
return unittest.TestSuite()

if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
5 changes: 0 additions & 5 deletions src/zc/catalog/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,4 @@
/>
</class>

<include
zcml:condition="installed zope.app.form"
package=".browser"
/>

</configure>

0 comments on commit 256df15

Please sign in to comment.