summaryrefslogtreecommitdiff
path: root/repoze
diff options
context:
space:
mode:
Diffstat (limited to 'repoze')
-rw-r--r--repoze/bfg/router.py25
-rw-r--r--repoze/bfg/tests/fixtureapp/subpackage/__init__.py1
-rw-r--r--repoze/bfg/tests/fixtureapp/subpackage/yetanother.zcml8
-rw-r--r--repoze/bfg/tests/test_router.py13
4 files changed, 39 insertions, 8 deletions
diff --git a/repoze/bfg/router.py b/repoze/bfg/router.py
index 3b9b12cb7..5addef933 100644
--- a/repoze/bfg/router.py
+++ b/repoze/bfg/router.py
@@ -225,17 +225,21 @@ def make_app(root_factory, package=None, filename='configure.zcml',
``package`` is a Python module representing the application's
package. It is optional, defaulting to ``None``. ``package`` may
- be ``None``. If ``package`` is ``None``, either the ``filename``
- passed or the value in the ``options`` dictionary named
- ``configure_zcml`` must be an absolute pathname to a ZCML file
- that represents the application's configuration.
+ be ``None``. If ``package`` is ``None``, the ``filename`` passed
+ or the value in the ``options`` dictionary named
+ ``configure_zcml`` must be a) absolute pathname to a ZCML file
+ that represents the application's configuration *or* b) a
+ 'specification' in the form
+ ``dotted_package_name:relative/file/path.zcml``.
``filename`` is the filesystem path to a ZCML file (optionally
relative to the package path) that should be parsed to create the
- application registry. It defaults to ``configure.zcml``. Note
- that if any value for ``configure_zcml`` is passed within the
- ``options`` dictionary, the value passed as ``filename`` will be
- ignored, replaced with the ``configure_zcml`` value.
+ application registry. It defaults to ``configure.zcml``. It can
+ also be a 'specification' in the form
+ ``dotted_package_name:relatve/file/path.zcml``. Note that if any
+ value for ``configure_zcml`` is passed within the ``options``
+ dictionary, the value passed as ``filename`` will be ignored,
+ replaced with the ``configure_zcml`` value.
``authentication_policy`` should be an object that implements the
``repoze.bfg.interfaces.IAuthenticationPolicy`` interface (e.g.
@@ -277,6 +281,11 @@ def make_app(root_factory, package=None, filename='configure.zcml',
settings = Settings(get_options(options))
filename = settings['configure_zcml']
+ if ':' in filename:
+ package, filename = filename.split(':', 1)
+ __import__(package)
+ package = sys.modules[package]
+
if registry is None:
regname = filename
if package:
diff --git a/repoze/bfg/tests/fixtureapp/subpackage/__init__.py b/repoze/bfg/tests/fixtureapp/subpackage/__init__.py
new file mode 100644
index 000000000..d3173e636
--- /dev/null
+++ b/repoze/bfg/tests/fixtureapp/subpackage/__init__.py
@@ -0,0 +1 @@
+#package
diff --git a/repoze/bfg/tests/fixtureapp/subpackage/yetanother.zcml b/repoze/bfg/tests/fixtureapp/subpackage/yetanother.zcml
new file mode 100644
index 000000000..464163477
--- /dev/null
+++ b/repoze/bfg/tests/fixtureapp/subpackage/yetanother.zcml
@@ -0,0 +1,8 @@
+<configure xmlns="http://namespaces.repoze.org/bfg">
+
+ <include package="repoze.bfg.includes" />
+
+ <include package="repoze.bfg.tests.fixtureapp" file="another.zcml"/>
+
+</configure>
+
diff --git a/repoze/bfg/tests/test_router.py b/repoze/bfg/tests/test_router.py
index cd88f8971..e3b200c57 100644
--- a/repoze/bfg/tests/test_router.py
+++ b/repoze/bfg/tests/test_router.py
@@ -703,6 +703,19 @@ class MakeAppTests(unittest.TestCase):
self.assertEqual(app.registry.__name__, 'repoze.bfg.tests.fixtureapp')
from repoze.bfg.tests.fixtureapp.models import IFixture
self.failIf(app.registry.queryUtility(IFixture)) # only in c.zcml
+
+ def test_fixtureapp_explicit_specification_in_options(self):
+ manager = DummyRegistryManager()
+ rootpolicy = DummyRootFactory(None)
+ from repoze.bfg.tests import fixtureapp
+ zcmlfile = 'repoze.bfg.tests.fixtureapp.subpackage:yetanother.zcml'
+ app = self._callFUT(rootpolicy, fixtureapp, filename='configure.zcml',
+ options={'configure_zcml':zcmlfile},
+ manager=manager)
+ self.assertEqual(app.registry.__name__,
+ 'repoze.bfg.tests.fixtureapp.subpackage')
+ from repoze.bfg.tests.fixtureapp.models import IFixture
+ self.failIf(app.registry.queryUtility(IFixture)) # only in c.zcml
def test_event(self):
manager = DummyRegistryManager()