From b29429e470c093573f3735b0dbf09d42c29cfe4d Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Fri, 2 Jul 2010 01:47:47 +0000 Subject: - The ``repoze.bfg.url.route_url`` API has changed. If a keyword ``_app_url`` is present in the arguments passed to ``route_url``, this value will be used as the protocol/hostname/port/leading path prefix of the generated URL. For example, using an ``_app_url`` of ``http://example.com:8080/foo`` would cause the URL ``http://example.com:8080/foo/fleeb/flub`` to be returned from this function if the expansion of the route pattern associated with the ``route_name`` expanded to ``/fleeb/flub``. - It is now possible to use a URL as the ``name`` argument fed to ``repoze.bfg.configuration.Configurator.add_static_view``. When the name argument is a URL, the ``repoze.bfg.url.static_url`` API will generate join this URL (as a prefix) to a path including the static file name. This makes it more possible to put static media on a separate webserver for production, while keeping static media package-internal and served by the development webserver during development. --- repoze/bfg/zcml.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'repoze/bfg/zcml.py') diff --git a/repoze/bfg/zcml.py b/repoze/bfg/zcml.py index 3e8bb0c50..d55dd1d1d 100644 --- a/repoze/bfg/zcml.py +++ b/repoze/bfg/zcml.py @@ -32,7 +32,7 @@ from repoze.bfg.exceptions import NotFound from repoze.bfg.exceptions import Forbidden from repoze.bfg.request import route_request_iface from repoze.bfg.resource import resource_spec_from_abspath -from repoze.bfg.static import StaticRootFactory +from repoze.bfg.static import StaticURLInfo from repoze.bfg.threadlocal import get_current_registry ###################### directives ########################## @@ -558,17 +558,19 @@ def static(_context, name, path, cache_max_age=3600): config = Configurator(reg, package=_context.package) _context.action( - discriminator = ('route', name, False, None, None, None, None, None), + discriminator=('static', name), callable=config.add_static_view, - args = (name, path, cache_max_age, _context.info), + args = (name, path), + kw = {'cache_max_age':cache_max_age, '_info':_context.info}, ) - _context.action( - discriminator = ( - 'view', StaticRootFactory, '', None, IView, None, None, None, - name, None, None, None, None, None, + if not '/' in name: + _context.action( + discriminator = ( + 'view', StaticURLInfo, '', None, IView, None, None, None, + name, None, None, None, None, None, + ) ) - ) class IScanDirective(Interface): package = GlobalObject( -- cgit v1.2.3