summaryrefslogtreecommitdiff
path: root/repoze/bfg/zcml.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-09-18 03:37:52 +0000
committerChris McDonough <chrism@agendaless.com>2009-09-18 03:37:52 +0000
commit600ea3d5c50c1907e5f389d3040644543fae9077 (patch)
tree725073bb67b91af507797f0ea709ed67304793af /repoze/bfg/zcml.py
parent43514664d60d00721bfe9b32d68c5d9dcdb2419a (diff)
downloadpyramid-600ea3d5c50c1907e5f389d3040644543fae9077.tar.gz
pyramid-600ea3d5c50c1907e5f389d3040644543fae9077.tar.bz2
pyramid-600ea3d5c50c1907e5f389d3040644543fae9077.zip
Centralize resource_spec code.
Diffstat (limited to 'repoze/bfg/zcml.py')
-rw-r--r--repoze/bfg/zcml.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py
index bbfc8164e..29e54df28 100644
--- a/repoze/bfg/zcml.py
+++ b/repoze/bfg/zcml.py
@@ -43,6 +43,7 @@ from repoze.bfg.interfaces import IRendererFactory
from repoze.bfg.path import package_name
from repoze.bfg.resource import PackageOverrides
+from repoze.bfg.resource import resource_spec
from repoze.bfg.request import create_route_request_factory
@@ -159,11 +160,7 @@ def view(
score = sys.maxint
if renderer and '.' in renderer:
- if (not ':' in renderer) and (not os.path.isabs(renderer) ):
- # if it's not a package:relative/name and it's not an
- # /absolute/path it's a relative/path; this means its relative
- # to the package in which the ZCML file is defined.
- renderer = '%s:%s' % (package_name(_context.resolve('.')), renderer)
+ renderer = resource_spec(renderer, package_name(_context.resolve('.')))
def register():
derived_view = derive_view(view, permission, predicates, attr, renderer,
@@ -502,12 +499,7 @@ class IStaticDirective(Interface):
def static(_context, name, path, cache_max_age=3600):
""" Handle ``static`` ZCML directives
"""
- if (not ':' in path) and (not os.path.isabs(path)):
- # if it's not a package:relative/name and it's not an
- # /absolute/path it's a relative/path; this means its relative
- # to the package in which the ZCML file is defined.
- path = '%s:%s' % (package_name(_context.resolve('.')), path)
-
+ path = resource_spec(path, package_name(_context.resolve('.')))
view = static_view(path, cache_max_age=cache_max_age)
route(_context, name, "%s*subpath" % name, view=view,
view_for=StaticRootFactory, factory=StaticRootFactory(path))