diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-06-30 21:02:00 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-06-30 21:02:00 +0000 |
| commit | d809ac74d19342bcc84e4fe043697709b2001cc0 (patch) | |
| tree | 9973b531b90336bf6ecf3811aa3b9ba753f4e6d8 /repoze/bfg/tests/test_templating.py | |
| parent | f9e73ea5a9d5a4210e3a346aa2f9483d70d22ab9 (diff) | |
| download | pyramid-d809ac74d19342bcc84e4fe043697709b2001cc0.tar.gz pyramid-d809ac74d19342bcc84e4fe043697709b2001cc0.tar.bz2 pyramid-d809ac74d19342bcc84e4fe043697709b2001cc0.zip | |
- Add a ``reload_resources`` configuration file setting (aka the
``BFG_RELOAD_RESOURCES`` environment variable). When this is set to
true, the server never needs to be restarted when moving files
between directory resource overrides (esp. for templates currently).
- Add a ``reload_all`` configuration file setting (aka the
``BFG_RELOAD_ALL`` environment variable) that implies both
``reload_resources`` and ``reload_templates``.
- The ``static`` helper view class now uses a ``PackageURLParser`` in
order to allow for the overriding of static resources (CSS / logo
files, etc) using the ``resource`` ZCML directive. The
``PackageURLParser`` class was added to a (new) ``static`` module in
BFG; it is a subclass of the ``StaticURLParser`` class in
``paste.urlparser``.
- The ``repoze.bfg.templating.renderer_from_cache`` function now
checks for the ``reload_resources`` setting; if it's true, it does
not register a template renderer (it won't use the registry as a
template renderer cache).
- Add ``pkg_resources`` to the glossary.
- Update the "Environment" docs to note the existence of
``reload_resources`` and ``reload_all``.
- Use a colon instead of a tab as the separator between package name
and relpath to form the "spec" when register a ITemplateRenderer.
Diffstat (limited to 'repoze/bfg/tests/test_templating.py')
| -rw-r--r-- | repoze/bfg/tests/test_templating.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/repoze/bfg/tests/test_templating.py b/repoze/bfg/tests/test_templating.py index d413acc2e..361cf6f7e 100644 --- a/repoze/bfg/tests/test_templating.py +++ b/repoze/bfg/tests/test_templating.py @@ -57,7 +57,7 @@ class TestRendererFromCache(unittest.TestCase): from repoze.bfg import tests module_name = tests.__name__ relpath = 'test_templating.py' - spec = '%s\t%s' % (module_name, relpath) + spec = '%s:%s' % (module_name, relpath) renderer = {} testing.registerUtility(renderer, ITemplateRenderer, name=spec) result = self._callFUT('test_templating.py', None) @@ -68,7 +68,6 @@ class TestRendererFromCache(unittest.TestCase): from repoze.bfg.tests import test_templating module_name = test_templating.__name__ relpath = 'test_templating.py' - spec = '%s\t%s' % (module_name, relpath) renderer = {} factory = DummyFactory(renderer) result = self._callFUT('test_templating.py', factory) @@ -79,6 +78,34 @@ class TestRendererFromCache(unittest.TestCase): self.assertEqual(factory.path, path) self.assertEqual(factory.kw, {}) + def test_relpath_notyetregistered_reload_resources_true(self): + from zope.component import queryUtility + from repoze.bfg.interfaces import ISettings + from repoze.bfg.interfaces import ITemplateRenderer + settings = {'reload_resources':True} + testing.registerUtility(settings, ISettings) + renderer = {} + factory = DummyFactory(renderer) + result = self._callFUT('test_templating.py', factory) + self.failUnless(result is renderer) + spec = '%s:%s' % ('repoze.bfg.tests', 'test_templating.py') + self.assertEqual(queryUtility(ITemplateRenderer, name=spec), + None) + + def test_relpath_notyetregistered_reload_resources_false(self): + from zope.component import queryUtility + from repoze.bfg.interfaces import ISettings + from repoze.bfg.interfaces import ITemplateRenderer + settings = {'reload_resources':False} + testing.registerUtility(settings, ISettings) + renderer = {} + factory = DummyFactory(renderer) + result = self._callFUT('test_templating.py', factory) + self.failUnless(result is renderer) + spec = '%s:%s' % ('repoze.bfg.tests', 'test_templating.py') + self.assertNotEqual(queryUtility(ITemplateRenderer, name=spec), + None) + class DummyFactory: def __init__(self, renderer): self.renderer = renderer |
