[CalendarServer-changes] [7528] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 26 09:42:46 PDT 2011
Revision: 7528
http://trac.macosforge.org/projects/calendarserver/changeset/7528
Author: sagen at apple.com
Date: 2011-05-26 09:42:45 -0700 (Thu, 26 May 2011)
Log Message:
-----------
AugmentService is no longer a global, it's an attribute on DirectoryService (9423236)
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/provision/test/test_root.py
CalendarServer/trunk/calendarserver/tap/util.py
CalendarServer/trunk/calendarserver/tools/principals.py
CalendarServer/trunk/calendarserver/tools/resources.py
CalendarServer/trunk/calendarserver/tools/test/test_export.py
CalendarServer/trunk/calendarserver/tools/test/test_gateway.py
CalendarServer/trunk/calendarserver/tools/test/test_resources.py
CalendarServer/trunk/calendarserver/tools/util.py
CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
CalendarServer/trunk/twistedcaldav/directory/augment.py
CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py
CalendarServer/trunk/twistedcaldav/directory/principal.py
CalendarServer/trunk/twistedcaldav/directory/test/test_aggregate.py
CalendarServer/trunk/twistedcaldav/directory/test/test_livedirectory.py
CalendarServer/trunk/twistedcaldav/directory/test/test_opendirectory.py
CalendarServer/trunk/twistedcaldav/directory/test/test_principal.py
CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipalmembers.py
CalendarServer/trunk/twistedcaldav/directory/test/test_xmlfile.py
CalendarServer/trunk/twistedcaldav/directory/xmlfile.py
CalendarServer/trunk/twistedcaldav/test/util.py
Modified: CalendarServer/trunk/calendarserver/provision/test/test_root.py
===================================================================
--- CalendarServer/trunk/calendarserver/provision/test/test_root.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/calendarserver/provision/test/test_root.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -61,10 +61,13 @@
RootResource.CheckSACL = FakeCheckSACL(sacls={"calendar": ["dreid"]})
- augment.AugmentService = augment.AugmentXMLDB(
- xmlFiles=(augmentsFile.path,)
+ directory = XMLDirectoryService(
+ {
+ "xmlFile" : xmlFile,
+ "augmentService" :
+ augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,))
+ }
)
- directory = XMLDirectoryService({"xmlFile" : xmlFile})
principals = DirectoryPrincipalProvisioningResource(
"/principals/",
Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/calendarserver/tap/util.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -211,7 +211,7 @@
log.info("Configuring augment service of type: %s" % (augmentClass,))
try:
- augment.AugmentService = augmentClass(**config.AugmentService.params)
+ augmentService = augmentClass(**config.AugmentService.params)
except IOError:
log.error("Could not start augment service")
raise
@@ -227,6 +227,7 @@
log.info("Configuring directory service of type: %s"
% (config.DirectoryService.type,))
+ config.DirectoryService.params.augmentService = augmentService
baseDirectory = directoryClass(config.DirectoryService.params)
# Wait for the directory to become available
@@ -243,6 +244,7 @@
log.info("Configuring resource service of type: %s" % (resourceClass,))
+ config.ResourceService.params.augmentService = augmentService
resourceDirectory = resourceClass(config.ResourceService.params)
resourceDirectory.realmName = baseDirectory.realmName
directories.append(resourceDirectory)
Modified: CalendarServer/trunk/calendarserver/tools/principals.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/principals.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/calendarserver/tools/principals.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -806,9 +806,10 @@
else:
record = directory.updateRecord(recordType, **kwargs)
- augmentRecord = (yield augment.AugmentService.getAugmentRecord(kwargs['guid'], recordType))
+ augmentService = directory.serviceForRecordType(recordType).augmentService
+ augmentRecord = (yield augmentService.getAugmentRecord(kwargs['guid'], recordType))
augmentRecord.autoSchedule = autoSchedule
- (yield augment.AugmentService.addAugmentRecords([augmentRecord]))
+ (yield augmentService.addAugmentRecords([augmentRecord]))
directory.updateRecord(recordType, **kwargs)
returnValue(record)
Modified: CalendarServer/trunk/calendarserver/tools/resources.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/resources.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/calendarserver/tools/resources.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -217,7 +217,7 @@
autoSchedule = autoSchedules.get(guid, 1)
else:
autoSchedule = True
- augmentRecord = (yield augment.AugmentService.getAugmentRecord(guid, recordType))
+ augmentRecord = (yield destService.augmentService.getAugmentRecord(guid, recordType))
augmentRecord.autoSchedule = autoSchedule
augmentRecords.append(augmentRecord)
@@ -233,7 +233,7 @@
destService.createRecords(directoryRecords)
- (yield augment.AugmentService.addAugmentRecords(augmentRecords))
+ (yield destService.augmentService.addAugmentRecords(augmentRecords))
Modified: CalendarServer/trunk/calendarserver/tools/test/test_export.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_export.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/calendarserver/tools/test/test_export.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -30,7 +30,6 @@
from twext.enterprise.ienterprise import AlreadyFinishedError
from twistedcaldav.ical import Component
-from twistedcaldav.directory import augment
from twistedcaldav.datafilters.test.test_peruserdata import dataForTwoUsers
from twistedcaldav.datafilters.test.test_peruserdata import resultForUser2
@@ -205,14 +204,6 @@
raise RuntimeError(
"Main called twice during this test; duplicate reactor run.")
- # In lieu of a configuration file, patch up the augment service and make
- # it so directoryFromConfig will return something useful. Don't
- # actually need to patch the augment service to a real fake; just patch
- # it so that trial will restore the previous one when this test has
- # completed.
-
- self.patch(augment, "AugmentService", None)
-
patchConfig(
self,
DirectoryService=dict(
Modified: CalendarServer/trunk/calendarserver/tools/test/test_gateway.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_gateway.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/calendarserver/tools/test/test_gateway.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -153,7 +153,8 @@
# This appears to be necessary in order for record.autoSchedule to
# reflect the change prior to the directory record expiration
- augment.AugmentService.refresh()
+ augmentService = directory.serviceForRecordType(directory.recordType_locations).augmentService
+ augmentService.refresh()
record = directory.recordWithUID("836B1B66-2E9A-4F46-8B1C-3DD6772C20B2")
self.assertEquals(record.fullName.decode("utf-8"), "Created Location 01 %s" % unichr(208))
@@ -187,7 +188,8 @@
# This appears to be necessary in order for record.autoSchedule to
# reflect the change
- augment.AugmentService.refresh()
+ augmentService = directory.serviceForRecordType(directory.recordType_locations).augmentService
+ augmentService.refresh()
record = directory.recordWithUID("836B1B66-2E9A-4F46-8B1C-3DD6772C20B2")
Modified: CalendarServer/trunk/calendarserver/tools/test/test_resources.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_resources.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/calendarserver/tools/test/test_resources.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -41,8 +41,9 @@
class StubDirectoryService(object):
- def __init__(self):
+ def __init__(self, augmentService):
self.records = {}
+ self.augmentService = augmentService
def recordWithGUID(self, guid):
return None
@@ -117,8 +118,7 @@
def queryMethod(sourceService, recordType, verbose=False):
return data[recordType]
- self.patch(augment, "AugmentService", StubAugmentService)
- directoryService = StubDirectoryService()
+ directoryService = StubDirectoryService(StubAugmentService())
yield migrateResources(None, directoryService, queryMethod=queryMethod)
for guid, recordType in (
('6C99E240-E915-4012-82FA-99E0F638D7EF', DirectoryService.recordType_resources),
Modified: CalendarServer/trunk/calendarserver/tools/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/util.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/calendarserver/tools/util.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -129,13 +129,14 @@
# Load augment/proxy db classes now
augmentClass = namedClass(config.AugmentService.type)
- augment.AugmentService = augmentClass(**config.AugmentService.params)
+ augmentService = augmentClass(**config.AugmentService.params)
proxydbClass = namedClass(config.ProxyDBService.type)
calendaruserproxy.ProxyDBService = proxydbClass(**config.ProxyDBService.params)
# Wait for directory service to become available
BaseDirectoryService = namedClass(config.DirectoryService.type)
+ config.DirectoryService.params.augmentService = augmentService
directory = BaseDirectoryService(config.DirectoryService.params)
while not directory.isAvailable():
sleep(5)
@@ -145,6 +146,7 @@
if config.ResourceService.Enabled:
resourceClass = namedClass(config.ResourceService.type)
+ config.ResourceService.params.augmentService = augmentService
resourceDirectory = resourceClass(config.ResourceService.params)
resourceDirectory.realmName = directory.realmName
directories.append(resourceDirectory)
Modified: CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -77,6 +77,7 @@
self.recordType_users,
self.recordType_groups,
),
+ 'augmentService' : None,
}
ignored = ('requireComputerRecord',)
params = self.getParams(params, defaults, ignored)
@@ -94,6 +95,7 @@
self.log_error("OpenDirectory (node=%s) Initialization error: %s" % (params['node'], e))
raise
+ self.augmentService = params['augmentService']
self.realmName = params['node']
self.directory = directory
self.node = params['node']
@@ -470,7 +472,7 @@
# TODO: this needs to be deferred but for now we hard code
# the deferred result because we know it is completing
# immediately.
- d = augment.AugmentService.getAugmentRecord(record.guid,
+ d = self.augmentService.getAugmentRecord(record.guid,
recordType)
d.addCallback(lambda x:record.addAugmentInformation(x))
@@ -757,7 +759,7 @@
# Look up augment information
# TODO: this needs to be deferred but for now we hard code the deferred result because
# we know it is completing immediately.
- d = augment.AugmentService.getAugmentRecord(record.guid,
+ d = self.augmentService.getAugmentRecord(record.guid,
recordType)
d.addCallback(lambda x:record.addAugmentInformation(x))
Modified: CalendarServer/trunk/twistedcaldav/directory/augment.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/augment.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/augment.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -201,8 +201,6 @@
"""
raise NotImplementedError("Child class must define this.")
-
-AugmentService = AugmentDB() # Global augment service
class AugmentXMLDB(AugmentDB):
Modified: CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -74,6 +74,7 @@
"""
defaults = {
+ "augmentService" : None,
"cacheTimeout": 1,
"negativeCaching": False,
"restrictEnabledRecords": False,
@@ -141,6 +142,7 @@
super(LdapDirectoryService, self).__init__(params["cacheTimeout"],
params["negativeCaching"])
+ self.augmentService = params["augmentService"]
self.realmName = params["uri"]
self.uri = params["uri"]
self.tls = params["tls"]
@@ -444,7 +446,7 @@
# Look up augment information
# TODO: this needs to be deferred but for now we hard code the
# deferred result because we know it is completing immediately.
- d = augment.AugmentService.getAugmentRecord(record.guid,
+ d = self.augmentService.getAugmentRecord(record.guid,
recordType)
d.addCallback(lambda x:record.addAugmentInformation(x))
Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -790,9 +790,9 @@
@inlineCallbacks
def setAutoSchedule(self, autoSchedule):
self.record.autoSchedule = autoSchedule
- augmentRecord = (yield augment.AugmentService.getAugmentRecord(self.record.guid, self.record.recordType))
+ augmentRecord = (yield self.record.service.augmentService.getAugmentRecord(self.record.guid, self.record.recordType))
augmentRecord.autoSchedule = autoSchedule
- (yield augment.AugmentService.addAugmentRecords([augmentRecord]))
+ (yield self.record.service.augmentService.addAugmentRecords([augmentRecord]))
def getAutoSchedule(self):
return self.record.autoSchedule
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_aggregate.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_aggregate.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_aggregate.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -62,8 +62,13 @@
"""
Returns an IDirectoryService.
"""
- augment.AugmentService = augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,))
- xmlService = XMLDirectoryService({'xmlFile' : xmlFile})
+ xmlService = XMLDirectoryService(
+ {
+ 'xmlFile' : xmlFile,
+ 'augmentService' :
+ augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,)),
+ }
+ )
xmlService.recordTypePrefix = xml_prefix
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_livedirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_livedirectory.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_livedirectory.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -67,9 +67,6 @@
from twistedcaldav.directory.test.test_xmlfile import augmentsFile
from twisted.internet.defer import inlineCallbacks
- augment.AugmentService = augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,))
-
-
class LiveDirectoryTests(object):
def test_ldapRecordWithShortName(self):
@@ -153,6 +150,8 @@
def setUp(self):
params = {
+ "augmentService":
+ augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,)),
"uri": "ldap://%s" % (testServer,),
"rdnSchema": {
"base": base,
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_opendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_opendirectory.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_opendirectory.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -55,9 +55,13 @@
def setUp(self):
super(OpenDirectory, self).setUp()
- augment.AugmentService = augment.AugmentXMLDB(xmlFiles=())
try:
- self._service = OpenDirectoryService({"node" : "/Search"})
+ self._service = OpenDirectoryService(
+ {
+ "node" : "/Search",
+ "augmentService": augment.AugmentXMLDB(xmlFiles=()),
+ }
+ )
except ImportError, e:
raise SkipTest("OpenDirectory module is not available: %s" % (e,))
@@ -451,10 +455,10 @@
def setUp(self):
super(OpenDirectorySubset, self).setUp()
- augment.AugmentService = augment.AugmentXMLDB(xmlFiles=())
self._service = OpenDirectoryService(
{
"node" : "/Search",
"recordTypes" : (DirectoryService.recordType_users, DirectoryService.recordType_groups),
+ "augmentService" : augment.AugmentXMLDB(xmlFiles=()),
}
)
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_principal.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_principal.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -53,11 +53,12 @@
def setUp(self):
super(ProvisionedPrincipals, self).setUp()
- augment.AugmentService = augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,))
self.directoryServices = (
XMLDirectoryService(
{
'xmlFile' : xmlFile,
+ 'augmentService' :
+ augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,)),
}
),
)
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipalmembers.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipalmembers.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipalmembers.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -38,8 +38,13 @@
def setUp(self):
super(ProxyPrincipals, self).setUp()
- augment.AugmentService = augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,))
- self.directoryService = XMLDirectoryService({'xmlFile' : xmlFile})
+ self.directoryService = XMLDirectoryService(
+ {
+ 'xmlFile' : xmlFile,
+ 'augmentService' :
+ augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,)),
+ }
+ )
calendaruserproxy.ProxyDBService = calendaruserproxy.ProxySqliteDB("proxies.sqlite")
# Set up a principals hierarchy for each service we're testing with
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_xmlfile.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_xmlfile.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_xmlfile.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -97,9 +97,14 @@
Test XML file based directory implementation.
"""
def service(self):
- self.patch(augment, "AugmentService",
- augment.AugmentXMLDB(xmlFiles=(self.augmentsFile().path,)))
- directory = XMLDirectoryService({'xmlFile' : self.xmlFile()}, alwaysStat=True)
+ directory = XMLDirectoryService(
+ {
+ 'xmlFile' : self.xmlFile(),
+ 'augmentService' :
+ augment.AugmentXMLDB(xmlFiles=(self.augmentsFile().path,)),
+ },
+ alwaysStat=True
+ )
return directory
def test_changedXML(self):
@@ -162,7 +167,7 @@
</augments>
"""
)
- augment.AugmentService.refresh()
+ service.augmentService.refresh()
for recordType, expectedRecords in (
( DirectoryService.recordType_users , () ),
@@ -316,12 +321,17 @@
))
def test_recordTypesSubset(self):
- self.patch(augment, "AugmentService",
- augment.AugmentXMLDB(xmlFiles=(self.augmentsFile().path,)))
directory = XMLDirectoryService(
- {'xmlFile' : self.xmlFile(),
- 'recordTypes' : (DirectoryService.recordType_users,
- DirectoryService.recordType_groups)},
+ {
+ 'xmlFile' : self.xmlFile(),
+ 'augmentService' :
+ augment.AugmentXMLDB(xmlFiles=(self.augmentsFile().path,)),
+ 'recordTypes' :
+ (
+ DirectoryService.recordType_users,
+ DirectoryService.recordType_groups
+ ),
+ },
alwaysStat=True
)
self.assertEquals(set(("users", "groups")), set(directory.recordTypes()))
Modified: CalendarServer/trunk/twistedcaldav/directory/xmlfile.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/xmlfile.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/directory/xmlfile.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -70,6 +70,7 @@
),
'realmName' : '/Search',
'statSeconds' : 15,
+ 'augmentService' : None,
}
ignored = None
params = self.getParams(params, defaults, ignored)
@@ -77,6 +78,7 @@
self._recordTypes = params['recordTypes']
self.realmName = params['realmName']
self.statSeconds = params['statSeconds']
+ self.augmentService = params['augmentService']
super(XMLDirectoryService, self).__init__()
@@ -169,7 +171,7 @@
shortNames = tuple(xmlAccountRecord.shortNames),
xmlPrincipal = xmlAccountRecord,
)
- d = augment.AugmentService.getAugmentRecord(record.guid,
+ d = self.augmentService.getAugmentRecord(record.guid,
record.recordType)
d.addCallback(lambda x:record.addAugmentInformation(x))
Modified: CalendarServer/trunk/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/util.py 2011-05-26 00:16:14 UTC (rev 7527)
+++ CalendarServer/trunk/twistedcaldav/test/util.py 2011-05-26 16:42:45 UTC (rev 7528)
@@ -80,15 +80,13 @@
self.xmlFile = FilePath(config.DataRoot).child("accounts.xml")
self.xmlFile.setContent(xmlFile.getContent())
- # *temporarily* set up an augment service so this directory service will
- # work.
- self.patch(augment, "AugmentService", augment.AugmentXMLDB(
- xmlFiles=(augmentsFile.path,)
- )
- )
self.directoryService = XMLDirectoryService(
- {'xmlFile' : "accounts.xml"}
+ {
+ "xmlFile" : "accounts.xml",
+ "augmentService" :
+ augment.AugmentXMLDB( xmlFiles=(augmentsFile.path,)),
+ }
)
# FIXME: see FIXME in DirectoryPrincipalProvisioningResource.__init__;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110526/85397843/attachment-0001.html>
More information about the calendarserver-changes
mailing list