app: BaseApplication: Remove setup_routes method

Originally, I envisioned the `BaseApplication` class calling its
`setup_routes` method to set up the request dispatcher, eliminating the
need for subclasses to explicitly call it. This is unlikely to work,
however, as it will end up being called too early, as there will not yet
have been a chance to update the application configuration dictionary.
If any controller callables use the application configuration when they
are initialized, they will not have correct information.

As such, I decided to go ahead and remove this method and let subclasses
implement and call it when it makes sense.
master 1.0
Dustin 2016-07-15 09:55:56 -05:00
parent c97d570f66
commit 7fcbff018b
1 changed files with 1 additions and 10 deletions

View File

@ -63,7 +63,7 @@ class BaseApplication(object):
def __init__(self):
self.config = self.DEFAULT_CONFIG.copy()
self.setup_routes()
self.dispatcher = None
def __call__(self, environ, start_response):
start_response = StartResponseWrapper(start_response)
@ -148,15 +148,6 @@ class BaseApplication(object):
if filename and os.access(filename, os.R_OK):
self.config.update(util.read_config(filename))
def setup_routes(self):
'''Initialize the request dispatcher
The default implementation of this method does nothing, but it
is called when an instance of :py:class:`BaseApplication` is
created, and can be used by subclasses to set up the request
dispatcher.
'''
def make_request(self, environ):
'''Create a :py:class:`~milla.Request` from a WSGI environment