Revision
12749
Author
wsanchez@apple.com
Date
2014-02-25 12:59:45 -0800 (Tue, 25 Feb 2014)

Log Message

Clean up reload logic

Modified Paths

Diff

Modified: CalendarServer/trunk/calendarserver/webadmin/landing.py (12748 => 12749)


--- CalendarServer/trunk/calendarserver/webadmin/landing.py	2014-02-25 20:08:59 UTC (rev 12748)
+++ CalendarServer/trunk/calendarserver/webadmin/landing.py	2014-02-25 20:59:45 UTC (rev 12749)
@@ -27,9 +27,9 @@
 
 from .resource import PageElement, TemplateResource
 from .resource import WebAdminResource
-# from .logs import LogsResource
-# from .principals import PrincipalsResource
-# from .work import WorkMonitorResource
+from .logs import LogsResource
+from .principals import PrincipalsResource
+from .work import WorkMonitorResource
 
 from . import logs, principals, work
 
@@ -58,6 +58,7 @@
 
     addSlash = True
 
+
     def __init__(self, path, root, directory, store, principalCollections=()):
         TemplateResource.__init__(self, WebAdminLandingPageElement)
 
@@ -67,9 +68,9 @@
         # self._root = root
         # self._principalCollections = principalCollections
 
-        # self.putChild(u"logs", LogsResource())
-        # self.putChild(u"principals", PrincipalsResource(directory))
-        # self.putChild(u"work", WorkMonitorResource(store))
+        self.putChild(u"logs", LogsResource())
+        self.putChild(u"principals", PrincipalsResource(directory))
+        self.putChild(u"work", WorkMonitorResource(store))
 
         self.putChild(
             u"old",
@@ -80,9 +81,21 @@
 
 
     def getChild(self, name):
+        bound = super(WebAdminLandingResource, self).getChild(name)
+
+        if bound is not None:
+            return bound
+
+        #
+        # Dynamically load and vend child resources not bound using putChild()
+        # in __init__().  This is useful for development, since it allows one
+        # to comment out the putChild() call above, and then code will be
+        # re-loaded for each request.
+        #
+
         if name == u"logs":
             reload(logs)
-            resource = logs.LogsResource()
+            return logs.LogsResource()
 
         elif name == u"principals":
             reload(principals)
@@ -92,4 +105,4 @@
             reload(work)
             return work.WorkMonitorResource(self.store)
 
-        return super(WebAdminLandingResource, self).getChild(name)
+        return None