[CalendarServer-changes] [13540] CalendarServer/trunk/calendarserver/webadmin

source_changes at macosforge.org source_changes at macosforge.org
Tue May 27 14:11:52 PDT 2014


Revision: 13540
          http://trac.calendarserver.org//changeset/13540
Author:   cdaboo at apple.com
Date:     2014-05-27 14:11:51 -0700 (Tue, 27 May 2014)
Log Message:
-----------
Admin resources all need to be DAV resources since they are under / which is also DAV. Clean-up some related bits.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/webadmin/config.py
    CalendarServer/trunk/calendarserver/webadmin/eventsource.py
    CalendarServer/trunk/calendarserver/webadmin/landing.py
    CalendarServer/trunk/calendarserver/webadmin/logs.py
    CalendarServer/trunk/calendarserver/webadmin/principals.py
    CalendarServer/trunk/calendarserver/webadmin/resource.py
    CalendarServer/trunk/calendarserver/webadmin/test/test_eventsource.py
    CalendarServer/trunk/calendarserver/webadmin/work.py
    CalendarServer/trunk/calendarserver/webadmin/work.xhtml

Modified: CalendarServer/trunk/calendarserver/webadmin/config.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/config.py	2014-05-27 20:18:54 UTC (rev 13539)
+++ CalendarServer/trunk/calendarserver/webadmin/config.py	2014-05-27 21:11:51 UTC (rev 13540)
@@ -37,7 +37,7 @@
     """
 
     def __init__(self, configuration):
-        PageElement.__init__(self, u"config")
+        super(ConfigurationPageElement, self).__init__(u"config")
 
         self.configuration = configuration
 
@@ -151,7 +151,7 @@
     addSlash = False
 
 
-    def __init__(self, configuration):
-        TemplateResource.__init__(
-            self, lambda: ConfigurationPageElement(configuration)
+    def __init__(self, configuration, principalCollections):
+        super(ConfigurationResource, self).__init__(
+            lambda: ConfigurationPageElement(configuration), principalCollections, isdir=False
         )

Modified: CalendarServer/trunk/calendarserver/webadmin/eventsource.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/eventsource.py	2014-05-27 20:18:54 UTC (rev 13539)
+++ CalendarServer/trunk/calendarserver/webadmin/eventsource.py	2014-05-27 21:11:51 UTC (rev 13540)
@@ -30,10 +30,11 @@
 
 from zope.interface import implementer, Interface
 
+from twistedcaldav.simpleresource import SimpleResource
+
 from twisted.internet.defer import Deferred, succeed
 
 from txweb2.stream import IByteStream, fallbackSplit
-from txweb2.resource import Resource
 from txweb2.http_headers import MimeType
 from txweb2.http import Response
 
@@ -122,7 +123,7 @@
 
 
 
-class EventSourceResource(Resource):
+class EventSourceResource(SimpleResource):
     """
     Resource that vends HTML5 EventSource events.
 
@@ -132,7 +133,7 @@
     addSlash = False
 
 
-    def __init__(self, eventDecoder, bufferSize=400):
+    def __init__(self, eventDecoder, principalCollections, bufferSize=400):
         """
         @param eventDecoder: An object that can be used to extract data from
             an event for encoding into an EventSource data stream.
@@ -142,7 +143,7 @@
             buffer.
         @type bufferSize: L{int}
         """
-        Resource.__init__(self)
+        super(EventSourceResource, self).__init__(principalCollections, isdir=False)
 
         self._eventDecoder = eventDecoder
         self._events = deque(maxlen=bufferSize)
@@ -200,7 +201,7 @@
             C{events}.  Vending will resume starting from the following event.
         @type lastID: L{int}
         """
-        object.__init__(self)
+        super(EventStream, self).__init__()
 
         self._eventDecoder = eventDecoder
         self._events = events

Modified: CalendarServer/trunk/calendarserver/webadmin/landing.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/landing.py	2014-05-27 20:18:54 UTC (rev 13539)
+++ CalendarServer/trunk/calendarserver/webadmin/landing.py	2014-05-27 21:11:51 UTC (rev 13540)
@@ -35,7 +35,7 @@
     """
 
     def __init__(self):
-        PageElement.__init__(self, u"landing")
+        super(WebAdminLandingPageElement, self).__init__(u"landing")
 
 
     def pageSlots(self):
@@ -54,7 +54,7 @@
 
 
     def __init__(self, path, root, directory, store, principalCollections=()):
-        TemplateResource.__init__(self, WebAdminLandingPageElement)
+        super(WebAdminLandingResource, self).__init__(WebAdminLandingPageElement, principalCollections, True)
 
         from twistedcaldav.config import config as configuration
 
@@ -65,11 +65,11 @@
         # self._root = root
         # self._principalCollections = principalCollections
 
-        from .config import ConfigurationResource
-        self.putChild(u"config", ConfigurationResource(configuration))
+        #from .config import ConfigurationResource
+        #self.putChild(u"config", ConfigurationResource(configuration, principalCollections))
 
-        from .principals import PrincipalsResource
-        self.putChild(u"principals", PrincipalsResource(directory, store))
+        #from .principals import PrincipalsResource
+        #self.putChild(u"principals", PrincipalsResource(directory, store, principalCollections))
 
         # from .logs import LogsResource
         # self.putChild(u"logs", LogsResource())
@@ -95,18 +95,18 @@
 
         if name == u"config":
             reload(config)
-            return config.ConfigurationResource(self.configuration)
+            return config.ConfigurationResource(self.configuration, self._principalCollections)
 
         elif name == u"principals":
             reload(principals)
-            return principals.PrincipalsResource(self.directory, self.store)
+            return principals.PrincipalsResource(self.directory, self.store, self._principalCollections)
 
         elif name == u"logs":
             reload(logs)
-            return logs.LogsResource()
+            return logs.LogsResource(self._principalCollections)
 
         elif name == u"work":
             reload(work)
-            return work.WorkMonitorResource(self.store)
+            return work.WorkMonitorResource(self.store, self._principalCollections)
 
         return None

Modified: CalendarServer/trunk/calendarserver/webadmin/logs.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/logs.py	2014-05-27 20:18:54 UTC (rev 13539)
+++ CalendarServer/trunk/calendarserver/webadmin/logs.py	2014-05-27 21:11:51 UTC (rev 13540)
@@ -43,7 +43,7 @@
     """
 
     def __init__(self):
-        PageElement.__init__(self, u"logs")
+        super(LogsPageElement, self).__init__(u"logs")
 
 
     def pageSlots(self):
@@ -61,10 +61,10 @@
     addSlash = True
 
 
-    def __init__(self):
-        TemplateResource.__init__(self, LogsPageElement)
+    def __init__(self, principalCollections):
+        super(LogsResource, self).__init__(LogsPageElement, principalCollections, isdir=False)
 
-        self.putChild(u"events", LogEventsResource())
+        self.putChild(u"events", LogEventsResource(principalCollections))
 
 
 
@@ -73,8 +73,8 @@
     Log event vending resource.
     """
 
-    def __init__(self):
-        EventSourceResource.__init__(self, EventDecoder)
+    def __init__(self, principalCollections):
+        super(LogEventsResource, self).__init__(EventDecoder, principalCollections)
 
         self.observers = (
             AccessLogObserver(self),
@@ -133,7 +133,7 @@
     """
 
     def __init__(self, resource):
-        CommonAccessLoggingObserverExtensions.__init__(self)
+        super(AccessLogObserver, self).__init__()
 
         self._resource = resource
 

Modified: CalendarServer/trunk/calendarserver/webadmin/principals.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/principals.py	2014-05-27 20:18:54 UTC (rev 13539)
+++ CalendarServer/trunk/calendarserver/webadmin/principals.py	2014-05-27 21:11:51 UTC (rev 13540)
@@ -28,11 +28,12 @@
 from cStringIO import StringIO
 from zipfile import ZipFile
 
+from twistedcaldav.simpleresource import SimpleResource
+
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.web.template import tags as html, renderer
 
 from txweb2.stream import MemoryStream
-from txweb2.resource import Resource
 from txweb2.http import Response
 from txweb2.http_headers import MimeType
 
@@ -46,7 +47,7 @@
     """
 
     def __init__(self, directory):
-        PageElement.__init__(self, u"principals")
+        super(PrincipalsPageElement, self).__init__(u"principals")
 
         self._directory = directory
 
@@ -112,9 +113,9 @@
     addSlash = True
 
 
-    def __init__(self, directory, store):
-        TemplateResource.__init__(
-            self, lambda: PrincipalsPageElement(directory)
+    def __init__(self, directory, store, principalCollections):
+        super(PrincipalsResource, self).__init__(
+            lambda: PrincipalsPageElement(directory), principalCollections, isdir=False
         )
 
         self._directory = directory
@@ -129,7 +130,7 @@
         record = yield self._directory.recordWithUID(name)
 
         if record:
-            returnValue(PrincipalResource(record, self._store))
+            returnValue(PrincipalResource(record, self._store, self._principalCollections))
         else:
             returnValue(None)
 
@@ -141,7 +142,7 @@
     """
 
     def __init__(self, record):
-        PageElement.__init__(self, u"principals_edit")
+        super(PrincipalPageElement, self).__init__(u"principals_edit")
 
         self._record = record
 
@@ -168,9 +169,9 @@
     addSlash = True
 
 
-    def __init__(self, record, store):
-        TemplateResource.__init__(
-            self, lambda: PrincipalPageElement(record)
+    def __init__(self, record, store, principalCollections):
+        super(PrincipalResource, self).__init__(
+            lambda: PrincipalPageElement(record), principalCollections, isdir=False
         )
 
         self._record = record
@@ -182,11 +183,11 @@
             return self
 
         if name == "calendars_combined":
-            return PrincipalCalendarsExportResource(self._record, self._store)
+            return PrincipalCalendarsExportResource(self._record, self._store, self._principalCollections)
 
 
 
-class PrincipalCalendarsExportResource(Resource):
+class PrincipalCalendarsExportResource(SimpleResource):
     """
     Resource that vends a principal's calendars as iCalendar text.
     """
@@ -194,8 +195,8 @@
     addSlash = False
 
 
-    def __init__(self, record, store):
-        Resource.__init__(self)
+    def __init__(self, record, store, principalCollections):
+        super(PrincipalCalendarsExportResource, self).__init__(principalCollections, isdir=False)
 
         self._record = record
         self._store = store

Modified: CalendarServer/trunk/calendarserver/webadmin/resource.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/resource.py	2014-05-27 20:18:54 UTC (rev 13539)
+++ CalendarServer/trunk/calendarserver/webadmin/resource.py	2014-05-27 21:11:51 UTC (rev 13540)
@@ -24,6 +24,8 @@
     "TemplateResource",
 ]
 
+from twistedcaldav.simpleresource import SimpleResource
+
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.python.modules import getModule
 from twisted.web.template import (
@@ -31,7 +33,6 @@
 )
 
 from txweb2.stream import MemoryStream
-from txweb2.resource import Resource
 from txweb2.http import Response
 from txweb2.http_headers import MimeType
 
@@ -43,7 +44,7 @@
     """
 
     def __init__(self, templateName):
-        Element.__init__(self)
+        super(PageElement, self).__init__()
 
         self.loader = XMLFile(
             getModule(__name__).filePath.sibling(
@@ -76,7 +77,7 @@
 
 
 
-class TemplateResource(Resource):
+class TemplateResource(SimpleResource):
     """
     Resource that renders a template.
     """
@@ -92,8 +93,8 @@
     # def queryValues(request, arguments):
     #     return request.args.get(arguments, [])
 
-    def __init__(self, elementClass):
-        Resource.__init__(self)
+    def __init__(self, elementClass, pc, isdir):
+        super(TemplateResource, self).__init__(pc, isdir=isdir)
 
         self.elementClass = elementClass
 

Modified: CalendarServer/trunk/calendarserver/webadmin/test/test_eventsource.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/test/test_eventsource.py	2014-05-27 20:18:54 UTC (rev 13539)
+++ CalendarServer/trunk/calendarserver/webadmin/test/test_eventsource.py	2014-05-27 21:11:51 UTC (rev 13540)
@@ -121,7 +121,7 @@
     """
 
     def eventSourceResource(self):
-        return EventSourceResource(DictionaryEventDecoder)
+        return EventSourceResource(DictionaryEventDecoder, None)
 
 
     def render(self, resource):

Modified: CalendarServer/trunk/calendarserver/webadmin/work.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/work.py	2014-05-27 20:18:54 UTC (rev 13539)
+++ CalendarServer/trunk/calendarserver/webadmin/work.py	2014-05-27 21:11:51 UTC (rev 13540)
@@ -58,7 +58,7 @@
     """
 
     def __init__(self):
-        PageElement.__init__(self, u"work")
+        super(WorkMonitorPageElement, self).__init__(u"work")
 
 
     def pageSlots(self):
@@ -76,12 +76,12 @@
     addSlash = True
 
 
-    def __init__(self, store):
-        TemplateResource.__init__(
-            self, lambda: WorkMonitorPageElement()
+    def __init__(self, store, principalCollections):
+        super(WorkMonitorResource, self).__init__(
+            lambda: WorkMonitorPageElement(), principalCollections, isdir=False
         )
 
-        self.putChild(u"events", WorkEventsResource(store))
+        self.putChild(u"events", WorkEventsResource(store, principalCollections))
 
 
 
@@ -93,8 +93,8 @@
     log = Logger()
 
 
-    def __init__(self, store, pollInterval=1000):
-        EventSourceResource.__init__(self, EventDecoder, bufferSize=100)
+    def __init__(self, store, principalCollections, pollInterval=1000):
+        super(WorkEventsResource, self).__init__(EventDecoder, principalCollections, bufferSize=100)
 
         self._store = store
         self._pollInterval = pollInterval
@@ -114,8 +114,8 @@
 
         self._polling = True
 
+        txn = self._store.newTransaction()
         try:
-            txn = self._store.newTransaction()
 
             # Look up all of the jobs
 
@@ -146,8 +146,8 @@
                     jobDict = dict(
                         job_jobID=job.jobID,
                         job_priority=job.priority,
+                        job_weight=job.weight,
                         job_notBefore=formatTime(job.notBefore),
-                        job_notAfter=formatTime(job.notAfter),
                     )
 
                     work = yield job.workItem()
@@ -214,7 +214,10 @@
 
         except:
             self._polling = False
+            yield txn.abort()
             raise
+        else:
+            yield txn.commit()
 
         # Schedule the next poll
 

Modified: CalendarServer/trunk/calendarserver/webadmin/work.xhtml
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/work.xhtml	2014-05-27 20:18:54 UTC (rev 13539)
+++ CalendarServer/trunk/calendarserver/webadmin/work.xhtml	2014-05-27 21:11:51 UTC (rev 13540)
@@ -96,8 +96,8 @@
         // Job management
         "job_jobID": "Job ID",
         "job_priority": "Job Priority",
+        "job_weight": "Job Weight",
         "job_notBefore": "Not Before",
-        "job_notAfter": "Not After",
 
         // Work item management
         "work_workID": "Work ID",
@@ -465,8 +465,8 @@
         <tr>
           <th>Job ID</th>
           <th>Priority</th>
+          <th>Weight</th>
           <th>Not Before</th>
-          <th>Not After</th>
         </tr>
       </thead>
       <tbody id="work_item_details_body" />
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140527/74561a71/attachment-0001.html>


More information about the calendarserver-changes mailing list