From 600ea3d5c50c1907e5f389d3040644543fae9077 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 18 Sep 2009 03:37:52 +0000 Subject: Centralize resource_spec code. --- repoze/bfg/zcml.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'repoze/bfg/zcml.py') 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)) -- cgit v1.2.3