-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurls.py
35 lines (28 loc) · 933 Bytes
/
urls.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
"""
urls
~~~~
URL definitions.
:copyright: 2009 by tipfy.org.
:license: BSD, see LICENSE.txt for more details.
"""
from tipfy import Rule, import_string
def get_rules(app):
"""Returns a list of URL rules for the application. The list can be
defined entirely here or in separate ``urls.py`` files.
:param app:
The WSGI application instance.
:return:
A list of class:`tipfy.Rule` instances.
"""
# Here we show an example of joining all rules from the
# ``apps_installed`` definition set in config.py.
rules = []
for app_module in app.get_config('tipfy', 'apps_installed'):
try:
# Load the urls module from the app and extend our rules.
app_rules = import_string('%s.urls' % app_module)
rules.extend(app_rules.get_rules(app))
except ImportError:
pass
return rules