Automatically create a Traverser instance if Application is given a root object
parent
f5f7e76dae
commit
d635e83431
|
@ -24,7 +24,7 @@ Please give me a docstring!
|
|||
from milla.controllers import FaviconController
|
||||
from milla.util import asbool
|
||||
from webob.exc import HTTPNotFound, WSGIHTTPException, HTTPMethodNotAllowed
|
||||
import milla.dispatch
|
||||
import milla.dispatch.traversal
|
||||
import webob
|
||||
|
||||
__all__ = ['Application']
|
||||
|
@ -36,9 +36,8 @@ class Application(object):
|
|||
alternatively, a root object that will be passed to a new
|
||||
:py:class:`milla.dispatch.traversal.Traverser`.
|
||||
|
||||
:param root: A root object, passed to a traverser, which is
|
||||
automatically created if a root is given
|
||||
:param dispatcher: An object implementing the dispatcher protocol
|
||||
:param obj: An object implementing the dispatcher protocol, or an
|
||||
object to be used as the root for a Traverser
|
||||
|
||||
``Application`` instances are WSGI applications.
|
||||
|
||||
|
@ -50,8 +49,11 @@ class Application(object):
|
|||
|
||||
DEFAULT_ALLOWED_METHODS = ['GET', 'HEAD']
|
||||
|
||||
def __init__(self, dispatcher):
|
||||
self.dispatcher = dispatcher
|
||||
def __init__(self, obj):
|
||||
if not hasattr(obj, 'resolve'):
|
||||
# Object is not a dispatcher, but the root object for traversal
|
||||
obj = milla.dispatch.traversal.Traverser(obj)
|
||||
self.dispatcher = obj
|
||||
self.config = {'milla.favicon': True}
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
|
|
Loading…
Reference in New Issue