blob: 534679dc50049f4f3e1a0fbb71c553e17c7e615e [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4#
5# BitBake Toaster Implementation
6#
7# Copyright (C) 2013 Intel Corporation
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License version 2 as
11# published by the Free Software Foundation.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License along
19# with this program; if not, write to the Free Software Foundation, Inc.,
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22from django.conf.urls import patterns, include, url
23from django.views.generic import RedirectView
24from django.views.decorators.cache import never_cache
25
26import logging
27
28logger = logging.getLogger("toaster")
29
30# Uncomment the next two lines to enable the admin:
31from django.contrib import admin
32admin.autodiscover()
33
34urlpatterns = patterns('',
35
36 # Examples:
37 # url(r'^toaster/', include('toaster.foo.urls')),
38
39 # Uncomment the admin/doc line below to enable admin documentation:
40 # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
41
42
43 # This is here to maintain backward compatibility and will be deprecated
44 # in the future.
45 url(r'^orm/eventfile$', 'bldcollector.views.eventfile'),
46
47 # if no application is selected, we have the magic toastergui app here
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050048 url(r'^$', never_cache(RedirectView.as_view(url='/toastergui/', permanent=True))),
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049)
50
51import toastermain.settings
52
53if toastermain.settings.FRESH_ENABLED:
54 urlpatterns.insert(1, url(r'', include('fresh.urls')))
55 #logger.info("Enabled django-fresh extension")
56
57if toastermain.settings.DEBUG_PANEL_ENABLED:
58 import debug_toolbar
59 urlpatterns.insert(1, url(r'', include(debug_toolbar.urls)))
60 #logger.info("Enabled django_toolbar extension")
61
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050062urlpatterns = [
63 # Uncomment the next line to enable the admin:
64 url(r'^admin/', include(admin.site.urls)),
65] + urlpatterns
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067# Automatically discover urls.py in various apps, beside our own
68# and map module directories to the patterns
69
70import os
71currentdir = os.path.dirname(__file__)
72for t in os.walk(os.path.dirname(currentdir)):
73 #if we have a virtualenv skip it to avoid incorrect imports
74 if os.environ.has_key('VIRTUAL_ENV') and os.environ['VIRTUAL_ENV'] in t[0]:
75 continue
76
77 if "urls.py" in t[2] and t[0] != currentdir:
78 modulename = os.path.basename(t[0])
79 # make sure we don't have this module name in
80 conflict = False
81 for p in urlpatterns:
82 if p.regex.pattern == '^' + modulename + '/':
83 conflict = True
84 if not conflict:
85 urlpatterns.insert(0, url(r'^' + modulename + '/', include ( modulename + '.urls')))
86 else:
87 logger.warn("Module \'%s\' has a regexp conflict, was not added to the urlpatterns" % modulename)
88
89from pprint import pformat
90#logger.debug("urlpatterns list %s", pformat(urlpatterns))