diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-06-29 10:18:10 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-06-29 10:18:10 +0000 |
| commit | 5f4b80e5a1508116271ae8a6087834fff8ee3825 (patch) | |
| tree | 36e941f40eb305add61f03381175b22e4c4e4297 /repoze/bfg/path.py | |
| parent | 60f06a229856bfd69edf2307ad80772563531a90 (diff) | |
| download | pyramid-5f4b80e5a1508116271ae8a6087834fff8ee3825.tar.gz pyramid-5f4b80e5a1508116271ae8a6087834fff8ee3825.tar.bz2 pyramid-5f4b80e5a1508116271ae8a6087834fff8ee3825.zip | |
- Use ``caller_package`` function instead of ``caller_module``
function within ``templating`` to avoid needing to name the caller
module in resource overrides (actually match docs).
- Make it possible to override templates stored directly in a module
with templates in a subdirectory of the same module, stored directly
within another module, or stored in a subdirectory of another module
(actually match docs).
Diffstat (limited to 'repoze/bfg/path.py')
| -rw-r--r-- | repoze/bfg/path.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/repoze/bfg/path.py b/repoze/bfg/path.py index 5b827f04b..b79ff3816 100644 --- a/repoze/bfg/path.py +++ b/repoze/bfg/path.py @@ -16,6 +16,16 @@ def caller_module(level=2): module = sys.modules[module_name] return module +def caller_package(level=2, caller_module=caller_module): + # caller_module in arglist for tests + module = caller_module(level+1) + if '__init__.py' in module.__file__: + # Module is a package + return module + # Go up one level to get package + package_name = module.__name__.rsplit('.', 1)[0] + return sys.modules[package_name] + def package_path(package): # computing the abspath is actually kinda expensive so we memoize # the result |
