diff options
author | ianb <devnull@localhost> | 2005-08-22 21:07:47 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2005-08-22 21:07:47 +0000 |
commit | 3359489aa9684e4c2a960561b9ce259c938b3948 (patch) | |
tree | 59a9cf381666f313ea2e6c948b5de1df691f95bc /paste/urlmap.py | |
parent | 3ec21376e3ec7a68b569b04dd4f7a669a0b11bc6 (diff) | |
download | paste-3359489aa9684e4c2a960561b9ce259c938b3948.tar.gz |
paste.deployify urlmap
Diffstat (limited to 'paste/urlmap.py')
-rw-r--r-- | paste/urlmap.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/paste/urlmap.py b/paste/urlmap.py index 5b52680..2bd1bd6 100644 --- a/paste/urlmap.py +++ b/paste/urlmap.py @@ -6,6 +6,17 @@ from docsupport import metadata __all__ = ['URLMap', 'PathProxyURLMap'] +def urlmap_factory(loader, global_conf, **local_conf): + if 'not_found_app' in local_conf: + not_found_app = local_conf.pop('not_found_app') + else: + not_found_app = None + urlmap = URLMap(global_conf, not_found_app=not_found_app) + for path, app_name in local_conf.items(): + app = loader.get_app(app_name, global_conf=global_conf) + urlmap[name] = app + return urlmap + class URLMap(DictMixin): """ @@ -23,16 +34,12 @@ class URLMap(DictMixin): the ``http://domain`` or with a domain of ``None`` any domain will be matched (so long as no other explicit domain matches). """ - def __init__(self): + def __init__(self, global_conf, not_found_app=None): self.applications = [] + if not_found_app is None: + not_found_app = global_conf('not_found_app') self.not_found_application = self.not_found_app - attr_not_found_application = metadata.Attribute(""" - An application that is run when no other application matches - the URL. (Note that the URL ``""`` is also a catch-all URL.) - By default this application returns a simple 404 Not Found - result.""") - norm_url_re = re.compile('//+') domain_url_re = re.compile('^(http|https)://') |