|
a/src/mediaserver/cdplugins/pycommon/routing.py |
|
b/src/mediaserver/cdplugins/pycommon/routing.py |
|
... |
|
... |
67 |
:type path: byte string.
|
67 |
:type path: byte string.
|
68 |
"""
|
68 |
"""
|
69 |
if path.startswith(self.base_url):
|
69 |
if path.startswith(self.base_url):
|
70 |
path = path.split(self.base_url, 1)[1]
|
70 |
path = path.split(self.base_url, 1)[1]
|
71 |
|
71 |
|
72 |
for view_fun, rules in self._rules.iteritems():
|
72 |
for view_fun, rules in self._rules.items():
|
73 |
for rule in rules:
|
73 |
for rule in rules:
|
74 |
if rule.match(path) is not None:
|
74 |
if rule.match(path) is not None:
|
75 |
return view_fun
|
75 |
return view_fun
|
76 |
return None
|
76 |
return None
|
77 |
|
77 |
|
|
... |
|
... |
116 |
|
116 |
|
117 |
def redirect(self, path):
|
117 |
def redirect(self, path):
|
118 |
self._dispatch(path)
|
118 |
self._dispatch(path)
|
119 |
|
119 |
|
120 |
def _dispatch(self, path):
|
120 |
def _dispatch(self, path):
|
121 |
for view_func, rules in self._rules.iteritems():
|
121 |
for view_func, rules in self._rules.items():
|
122 |
for rule in rules:
|
122 |
for rule in rules:
|
123 |
kwargs = rule.match(path)
|
123 |
kwargs = rule.match(path)
|
124 |
if kwargs is not None:
|
124 |
if kwargs is not None:
|
125 |
log("Dispatching to '%s', args: %s" % (view_func.__name__, kwargs))
|
125 |
log("Dispatching to '%s', args: %s" % (view_func.__name__, kwargs))
|
126 |
view_func(**kwargs)
|
126 |
view_func(**kwargs)
|