[CalendarServer-changes] [4249] CalendarServer/trunk/calendarserver
source_changes at macosforge.org
source_changes at macosforge.org
Tue May 12 21:50:15 PDT 2009
Revision: 4249
http://trac.macosforge.org/projects/calendarserver/changeset/4249
Author: sagen at apple.com
Date: 2009-05-12 21:50:15 -0700 (Tue, 12 May 2009)
Log Message:
-----------
Don't instantiate a directory object on each request
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tap/caldav.py
CalendarServer/trunk/calendarserver/webadmin/helper.py
CalendarServer/trunk/calendarserver/webadmin/resource.py
Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py 2009-05-13 01:24:16 UTC (rev 4248)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py 2009-05-13 04:50:15 UTC (rev 4249)
@@ -656,6 +656,8 @@
self.log_info("Setting up WebAdmin resource")
webAdmin = self.webAdminResourceClass(
config.WebCalendarRoot,
+ root,
+ directory,
principalCollections=(principalCollection,),
)
root.putChild("admin", webAdmin)
Modified: CalendarServer/trunk/calendarserver/webadmin/helper.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/helper.py 2009-05-13 01:24:16 UTC (rev 4248)
+++ CalendarServer/trunk/calendarserver/webadmin/helper.py 2009-05-13 04:50:15 UTC (rev 4249)
@@ -148,77 +148,3 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-def setup(config):
-
- setLogLevelForNamespace(None, "warn")
-
- directory = getDirectory(config)
- if config.Memcached["ClientEnabled"]:
- memcachepool.installPool(
- IPv4Address(
- 'TCP',
- config.Memcached["BindAddress"],
- config.Memcached["Port"]
- ),
- config.Memcached["MaxClients"]
- )
- if config.Notifications["Enabled"]:
- installNotificationClient(
- config.Notifications["InternalNotificationHost"],
- config.Notifications["InternalNotificationPort"],
- )
- principalCollection = directory.getPrincipalCollection()
- root = RootResource(
- config.DocumentRoot,
- principalCollections=(principalCollection,),
- )
- root.putChild("principals", principalCollection)
- calendarCollection = CalendarHomeProvisioningFile(
- os.path.join(config.DocumentRoot, "calendars"),
- directory, "/calendars/",
- )
- root.putChild("calendars", calendarCollection)
-
- return (directory, root)
-
-def getDirectory(config):
- BaseDirectoryService = namedClass(config.DirectoryService["type"])
-
- class MyDirectoryService (BaseDirectoryService):
- def getPrincipalCollection(self):
- if not hasattr(self, "_principalCollection"):
- from twistedcaldav.directory.principal import DirectoryPrincipalProvisioningResource
- self._principalCollection = DirectoryPrincipalProvisioningResource("/principals/", self)
-
- return self._principalCollection
-
- def setPrincipalCollection(self, coll):
- # See principal.py line 237: self.directory.principalCollection = self
- pass
-
- principalCollection = property(getPrincipalCollection, setPrincipalCollection)
-
- def calendarHomeForRecord(self, record):
- principal = self.principalCollection.principalForRecord(record)
- if principal:
- try:
- return principal._calendarHome()
- except AttributeError:
- pass
- return None
-
- def calendarHomeForShortName(self, recordType, shortName):
- principal = self.principalCollection.principalForShortName(recordType, shortName)
- if principal:
- try:
- return principal._calendarHome()
- except AttributeError:
- pass
- return None
-
- def principalForCalendarUserAddress(self, cua):
- return self.principalCollection.principalForCalendarUserAddress(cua)
-
-
- return MyDirectoryService(config.DirectoryService["params"])
-
Modified: CalendarServer/trunk/calendarserver/webadmin/resource.py
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/resource.py 2009-05-13 01:24:16 UTC (rev 4248)
+++ CalendarServer/trunk/calendarserver/webadmin/resource.py 2009-05-13 04:50:15 UTC (rev 4249)
@@ -43,6 +43,12 @@
class WebAdminResource (ReadOnlyResourceMixIn, DAVFile):
+ def __init__(self, path, root, directory, principalCollections=()):
+ self.root = root
+ self.directory = directory
+ super(WebAdminResource, self).__init__(path,
+ principalCollections=principalCollections)
+
# Only allow administrators to access
def defaultAccessControlList(self):
return davxml.ACL(*config.AdminACEs)
@@ -402,8 +408,7 @@
def render(self, request):
# Prepare the ResourceWrapper, which will be used to get and modify resource info.
- directory, root = setup(config)
- resourceWrapper = ResourceWrapper(root)
+ resourceWrapper = ResourceWrapper(self.root)
# The response-generation will be deferred.
def _defer(htmlContent):
@@ -418,6 +423,6 @@
return response
# Generate the HTML and return the response when it's ready.
- htmlContent = self.htmlContent(resourceWrapper, directory, request)
+ htmlContent = self.htmlContent(resourceWrapper, self.directory, request)
htmlContent.addCallback(_defer)
return htmlContent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090512/ad528d31/attachment-0001.html>
More information about the calendarserver-changes
mailing list