A few adustments to the routing and etc
This commit is contained in:
parent
73e0dbcca3
commit
0f63a9440d
@ -27,11 +27,12 @@ class MediagoblinApp(object):
|
|||||||
def __init__(self, database, user_template_path=None):
|
def __init__(self, database, user_template_path=None):
|
||||||
self.template_env = util.get_jinja_env(user_template_path)
|
self.template_env = util.get_jinja_env(user_template_path)
|
||||||
self.db = database
|
self.db = database
|
||||||
|
self.routing = routing.get_mapper()
|
||||||
|
|
||||||
def __call__(self, environ, start_response):
|
def __call__(self, environ, start_response):
|
||||||
request = Request(environ)
|
request = Request(environ)
|
||||||
path_info = request.path_info
|
path_info = request.path_info
|
||||||
route_match = routing.mapping.match(path_info)
|
route_match = self.routing.match(path_info)
|
||||||
|
|
||||||
# No matching page?
|
# No matching page?
|
||||||
if route_match is None:
|
if route_match is None:
|
||||||
@ -39,7 +40,7 @@ class MediagoblinApp(object):
|
|||||||
# added and if so, redirect
|
# added and if so, redirect
|
||||||
if not path_info.endswith('/') \
|
if not path_info.endswith('/') \
|
||||||
and request.method == 'GET' \
|
and request.method == 'GET' \
|
||||||
and routing.mapping.match(path_info + '/'):
|
and self.routing.match(path_info + '/'):
|
||||||
new_path_info = path_info + '/'
|
new_path_info = path_info + '/'
|
||||||
if request.GET:
|
if request.GET:
|
||||||
new_path_info = '%s?%s' % (
|
new_path_info = '%s?%s' % (
|
||||||
@ -56,7 +57,7 @@ class MediagoblinApp(object):
|
|||||||
request.matchdict = route_match
|
request.matchdict = route_match
|
||||||
request.app = self
|
request.app = self
|
||||||
request.template_env = self.template_env
|
request.template_env = self.template_env
|
||||||
request.urlgen = routes.URLGenerator(routing.mapping, environ)
|
request.urlgen = routes.URLGenerator(self.routing, environ)
|
||||||
|
|
||||||
return controller(request)(environ, start_response)
|
return controller(request)(environ, start_response)
|
||||||
|
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
from routes import Mapper
|
from routes import Mapper
|
||||||
|
|
||||||
|
def get_mapper():
|
||||||
mapping = Mapper()
|
mapping = Mapper()
|
||||||
mapping.minimization = False
|
mapping.minimization = False
|
||||||
|
|
||||||
mapping.connect(
|
mapping.connect(
|
||||||
"index", "/", controller="mediagoblin.views:root_view")
|
"index", "/",
|
||||||
|
controller="mediagoblin.views:root_view")
|
||||||
|
mapping.connect(
|
||||||
|
"test_submit", "/test_submit/",
|
||||||
|
controller="mediagoblin.views:submit_test")
|
||||||
|
|
||||||
|
return mapping
|
||||||
|
Loading…
x
Reference in New Issue
Block a user