summaryrefslogtreecommitdiff
path: root/flup
diff options
context:
space:
mode:
Diffstat (limited to 'flup')
-rw-r--r--flup/publisher.py24
-rw-r--r--flup/resolver/complex.py3
-rw-r--r--flup/resolver/function.py3
-rw-r--r--flup/resolver/importingmodule.py3
-rw-r--r--flup/resolver/module.py3
-rw-r--r--flup/resolver/nopathinfo.py3
-rw-r--r--flup/resolver/objectpath.py3
-rw-r--r--flup/resolver/resolver.py3
8 files changed, 17 insertions, 28 deletions
diff --git a/flup/publisher.py b/flup/publisher.py
index b02724a..73a8b30 100644
--- a/flup/publisher.py
+++ b/flup/publisher.py
@@ -421,12 +421,15 @@ class Publisher(object):
"""
_transactionClass = Transaction
- def __init__(self, resolver, transactionClass=None):
+ def __init__(self, resolver, transactionClass=None, error404=None):
self._resolver = resolver
if transactionClass is not None:
self._transactionClass = transactionClass
+ if error404 is not None:
+ self._error404 = error404
+
def _get_resolver(self):
return self._resolver
resolver = property(_get_resolver, None, None,
@@ -450,12 +453,7 @@ class Publisher(object):
func = self._resolver.resolve(transaction.request,
redirect=redirect)
if func is None:
- # See if there's a higher-level 404 page
- if hasattr(self._resolver, 'error404') and \
- self._resolver.error404 is not None:
- func = self._resolver.error404
- else:
- return self._error404(environ, start_response)
+ func = self._error404
try:
# Call the function.
@@ -484,13 +482,13 @@ class Publisher(object):
start_response(transaction.response.status, responseHeaders)
return transaction.response.body
- def _error404(self, environ, start_response):
+ def _error404(self, transaction):
"""Error page to display when resolver fails."""
- start_response('404 Not Found', [('Content-Type', 'text/html')])
- request_uri = environ.get('REQUEST_URI')
+ transaction.response.status = '404 Not Found'
+ request_uri = transaction.request.environ.get('REQUEST_URI')
if request_uri is None:
- request_uri = environ.get('SCRIPT_NAME', '') + \
- environ.get('PATH_INFO', '')
+ request_uri = transaction.request.environ.get('SCRIPT_NAME', '') + \
+ transaction.request.environ.get('PATH_INFO', '')
return ["""<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
@@ -499,7 +497,7 @@ class Publisher(object):
The requested URL %s was not found on this server.<p>
<hr>
%s</body></html>
-""" % (request_uri, environ.get('SERVER_SIGNATURE', ''))]
+""" % (request_uri, transaction.request.environ.get('SERVER_SIGNATURE', ''))]
class File(object):
"""
diff --git a/flup/resolver/complex.py b/flup/resolver/complex.py
index cd25e9c..c3016ea 100644
--- a/flup/resolver/complex.py
+++ b/flup/resolver/complex.py
@@ -54,8 +54,7 @@ class ComplexResolver(Resolver):
"""
_slashRE = re.compile(r'''/{2,}''')
- def __init__(self, **kw):
- super(ComplexResolver, self).__init__(**kw)
+ def __init__(self):
self.resolverMap = {}
def _canonicalUrl(self, url):
diff --git a/flup/resolver/function.py b/flup/resolver/function.py
index a759926..537caa3 100644
--- a/flup/resolver/function.py
+++ b/flup/resolver/function.py
@@ -39,8 +39,7 @@ class FunctionResolver(Resolver):
Can be used as a decorator and might actually have uses when used with
the ComplexResolver.
"""
- def __init__(self, func, **kw):
- super(FunctionResolver, self).__init__(**kw)
+ def __init__(self, func):
self._func = func
def resolve(self, request, redirect=False):
diff --git a/flup/resolver/importingmodule.py b/flup/resolver/importingmodule.py
index 19decad..af0d712 100644
--- a/flup/resolver/importingmodule.py
+++ b/flup/resolver/importingmodule.py
@@ -62,8 +62,7 @@ class ImportingModuleResolver(Resolver):
default_module = None
index_page = 'index'
- def __init__(self, path, defaultModule=NoDefault, index=NoDefault, **kw):
- super(ImportingModuleResolver, self).__init__(**kw)
+ def __init__(self, path, defaultModule=NoDefault, index=NoDefault):
self.path = path
if defaultModule is not NoDefault:
self.default_module = defaultModule
diff --git a/flup/resolver/module.py b/flup/resolver/module.py
index e174b54..1d635fb 100644
--- a/flup/resolver/module.py
+++ b/flup/resolver/module.py
@@ -52,8 +52,7 @@ class ModuleResolver(Resolver):
"""
index_page = 'index'
- def __init__(self, module, index=NoDefault, **kw):
- super(ModuleResolver, self).__init__(**kw)
+ def __init__(self, module, index=NoDefault):
self.module = module
if index is not NoDefault:
self.index_page = index
diff --git a/flup/resolver/nopathinfo.py b/flup/resolver/nopathinfo.py
index 0e3c866..e0f3182 100644
--- a/flup/resolver/nopathinfo.py
+++ b/flup/resolver/nopathinfo.py
@@ -37,8 +37,7 @@ class NoPathInfoResolver(Resolver):
what's needed to resolve the function). Optionally allows a trailing
slash.
"""
- def __init__(self, resolver, allowTrailingSlash=False, **kw):
- super(NoPathInfoResolver, self).__init__(**kw)
+ def __init__(self, resolver, allowTrailingSlash=False):
self._resolver = resolver
self._allowTrailingSlash = allowTrailingSlash
diff --git a/flup/resolver/objectpath.py b/flup/resolver/objectpath.py
index cd6f312..9b74c3f 100644
--- a/flup/resolver/objectpath.py
+++ b/flup/resolver/objectpath.py
@@ -56,7 +56,7 @@ class ObjectPathResolver(Resolver):
default_page = 'default'
def __init__(self, root, index=NoDefault, default=NoDefault,
- favorIndex=True, **kw):
+ favorIndex=True):
"""
root is the root object of your URL hierarchy. In CherryPy, this
would be cpg.root.
@@ -66,7 +66,6 @@ class ObjectPathResolver(Resolver):
which method is called when the URL has a trailing slash. If
True, the index method will be called. Otherwise, the default method.
"""
- super(ObjectPathResolver, self).__init__(**kw)
self.root = root
if index is not NoDefault:
self.index_page = index
diff --git a/flup/resolver/resolver.py b/flup/resolver/resolver.py
index ff07f1f..10de455 100644
--- a/flup/resolver/resolver.py
+++ b/flup/resolver/resolver.py
@@ -43,9 +43,6 @@ class Resolver(object):
When resolving an InternalRedirect, redirect will be True.
"""
- def __init__(self, error404=None):
- self.error404 = error404
-
def resolve(self, request, redirect=False):
raise NotImplementedError, self.__class__.__name__ + '.resolve'