blob: bbe403badaca9e7b16864890550bc99ffab801c0 [file] [log] [blame]
Scott Bakerbb7e84f2014-06-16 23:08:43 -07001#from home import DashboardWelcomeView, DashboardDynamicView
2#from tenant import TenantCreateSlice, TenantUpdateSlice, TenantDeleteSliceView, TenantAddOrRemoveSliverView, TenantPickSitesView, TenantViewData
3#from simulator import SimulatorView
4#from cdn import DashboardSummaryAjaxView, DashboardAddOrRemoveSliverView, DashboardAjaxView
5#from analytics import DashboardAnalyticsAjaxView
6#from customize import DashboardCustomize
7#from interactions import DashboardSliceInteractions
8#from test import DashboardUserSiteView
Scott Bakerc7325a42014-05-30 16:06:46 -07009
Scott Bakerbb7e84f2014-06-16 23:08:43 -070010from django.views.generic import View
11from django.conf.urls import patterns, url
12import os, sys
13import inspect
14import importlib
15
16# Find all modules in the current directory that have descendents of the View
17# object, and add them as globals to this module. Also, build up a list of urls
18# based on the "url" field of the view classes.
19
20sys_path_save = sys.path
21try:
22 # __import__() and importlib.import_module() both import modules from
23 # sys.path. So we make sure that the path where we can find the views is
24 # the first thing in sys.path.
25 view_dir = os.path.dirname(os.path.abspath(__file__))
26 sys.path = [view_dir] + sys.path
27 view_urls = []
28 for fn in os.listdir(view_dir):
29 pathname = os.path.join(view_dir,fn)
30 if os.path.isfile(pathname) and fn.endswith(".py") and (fn!="__init__.py"):
31 #module = imp.load_source(fn[:-3],pathname)
32 #module = importlib.import_module(fn[:-3])
33 module = __import__(fn[:-3])
34 for classname in dir(module):
35 c = getattr(module, classname, None)
36
37 if inspect.isclass(c) and issubclass(c, View) and (classname not in globals()):
38 globals()[classname] = c
39
40 view_url = getattr(c, "url", None)
41 if view_url:
42 view_urls.append( (view_url, classname, c) )
43finally:
44 sys.path = sys_path_save