[CalendarServer-changes] [6188] CalendarServer/branches/generic-sqlstore

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 26 07:07:19 PDT 2010


Revision: 6188
          http://trac.macosforge.org/projects/calendarserver/changeset/6188
Author:   cdaboo at apple.com
Date:     2010-08-26 07:07:16 -0700 (Thu, 26 Aug 2010)
Log Message:
-----------
Merged from trunk.

Modified Paths:
--------------
    CalendarServer/branches/generic-sqlstore/calendarserver/tap/util.py
    CalendarServer/branches/generic-sqlstore/contrib/performance/benchlib.py
    CalendarServer/branches/generic-sqlstore/contrib/performance/benchmark
    CalendarServer/branches/generic-sqlstore/contrib/performance/benchmark.py
    CalendarServer/branches/generic-sqlstore/contrib/performance/event.py
    CalendarServer/branches/generic-sqlstore/contrib/performance/vfreebusy.py
    CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/aggregate.py
    CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/calendar.py
    CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/directory.py
    CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/idirectory.py
    CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/test/test_aggregate.py

Added Paths:
-----------
    CalendarServer/branches/generic-sqlstore/contrib/performance/sample.sh
    CalendarServer/branches/generic-sqlstore/contrib/performance/setbackend
    CalendarServer/branches/generic-sqlstore/contrib/performance/setbackend.py
    CalendarServer/branches/generic-sqlstore/contrib/performance/svn-committime
    CalendarServer/branches/generic-sqlstore/contrib/performance/svn-revno
    CalendarServer/branches/generic-sqlstore/contrib/performance/upload
    CalendarServer/branches/generic-sqlstore/contrib/performance/upload.py

Property Changed:
----------------
    CalendarServer/branches/generic-sqlstore/


Property changes on: CalendarServer/branches/generic-sqlstore
___________________________________________________________________
Modified: svn:mergeinfo
   - /CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/wsanchez/transations:5515-5593
   + /CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/wsanchez/transations:5515-5593
/CalendarServer/trunk:6167-6187

Modified: CalendarServer/branches/generic-sqlstore/calendarserver/tap/util.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/calendarserver/tap/util.py	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/calendarserver/tap/util.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -175,7 +175,18 @@
         directory.userRecordTypes.insert(0,
             SudoDirectoryService.recordType_sudoers)
 
+
     #
+    # Use system-wide realm on OSX
+    #
+    try:
+        import ServerFoundation
+        realmName = ServerFoundation.XSAuthenticator.defaultRealm().encode("utf-8")
+        directory.setRealm(realmName)
+    except ImportError:
+        pass
+
+    #
     # Setup the Augment Service
     #
     augmentClass = namedClass(config.AugmentService.type)

Modified: CalendarServer/branches/generic-sqlstore/contrib/performance/benchlib.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/benchlib.py	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/benchlib.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -4,8 +4,6 @@
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.web.http_headers import Headers
 
-from protocol.url import URL
-
 from stats import Duration
 from httpclient import StringProducer, readBody
 
@@ -19,17 +17,17 @@
         self.principal = principal
 
     def deleteResource(self, url):
-        return self.agent.request('DELETE', 'http://%s%s' % (self.netloc, url.toString()))
+        return self.agent.request('DELETE', 'http://%s%s' % (self.netloc, url))
 
 
     def makeCalendar(self, url):
-        return self.agent.request('MKCALENDAR', 'http://%s%s' % (self.netloc, url.toString()))
+        return self.agent.request('MKCALENDAR', 'http://%s%s' % (self.netloc, url))
 
 
     def writeData(self, url, data, contentType):
         return self.agent.request(
             'PUT', 
-            'http://%s%s' % (self.netloc, url.toString()), 
+            'http://%s%s' % (self.netloc, url), 
             Headers({'content-type': [contentType]}), 
             StringProducer(data))
 
@@ -52,7 +50,7 @@
         "%s:%d" % (host, port),
         user=user, password=password,
         root=root, principal=principal)
-    cal = URL("/calendars/users/%s/%s/" % (user, calendar))
+    cal = "/calendars/users/%s/%s/" % (user, calendar)
     d = _serial([
             (account.deleteResource, (cal,)),
             (account.makeCalendar, (cal,))])

Modified: CalendarServer/branches/generic-sqlstore/contrib/performance/benchmark
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/benchmark	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/benchmark	2010-08-26 14:07:16 UTC (rev 6188)
@@ -1,4 +1,4 @@
 #!/usr/bin/python
 
 from benchmark import main
-main()
+raise SystemExit(main())

Modified: CalendarServer/branches/generic-sqlstore/contrib/performance/benchmark.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/benchmark.py	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/benchmark.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -1,4 +1,4 @@
-import sys, os
+import sys
 from os.path import dirname
 
 from signal import SIGINT
@@ -6,6 +6,8 @@
 
 from datetime import datetime
 
+from twisted.python.filepath import FilePath
+from twisted.python.usage import UsageError, Options, portCoerce
 from twisted.python.reflect import namedAny
 from twisted.internet.protocol import ProcessProtocol
 from twisted.protocols.basic import LineReceiver
@@ -66,10 +68,9 @@
 
 def instancePIDs(directory):
     pids = []
-    for pidfile in os.listdir(directory):
-        if pidfile.startswith('caldav-instance-'):
-            pidpath = os.path.join(directory, pidfile)
-            pidtext = file(pidpath).read()
+    for pidfile in directory.children():
+        if pidfile.basename().startswith('caldav-instance-'):
+            pidtext = pidfile.getContent()
             pid = int(pidtext)
             pids.append(pid)
     return pids
@@ -109,7 +110,7 @@
                 diff = when - self.start
                 if diff < 0:
                     print 'Completely bogus EXECUTE', self.start, when
-                else:        
+                else:
                     if cmd == 'EXECUTE':
                         accum = self.collector._execute
                     elif cmd == 'ITERNEXT':
@@ -165,7 +166,7 @@
         process = reactor.spawnProcess(
             IOMeasureConsumer(started, stopped, _DTraceParser(self)),
             "/usr/sbin/dtrace",
-            ["/usr/sbin/dtrace", 
+            ["/usr/sbin/dtrace",
              # process preprocessor macros
              "-C",
              # search for include targets in the source directory containing this file
@@ -207,9 +208,12 @@
 
 
 @inlineCallbacks
-def benchmark(directory, label, benchmarks):
+def benchmark(host, port, directory, label, benchmarks):
     # Figure out which pids we are benchmarking.
-    pids = instancePIDs(directory)
+    if directory:
+        pids = instancePIDs(directory)
+    else:
+        pids = []
 
     parameters = [1, 9, 81]
     samples = 200
@@ -221,7 +225,7 @@
         for p in parameters:
             print 'Parameter at', p
             dtrace = DTraceCollector("io_measure.d", pids)
-            data = yield measure(dtrace, p, samples)
+            data = yield measure(host, port, dtrace, p, samples)
             statistics[name][p] = data
 
     fObj = file(
@@ -230,13 +234,54 @@
     fObj.close()
 
 
+def logsCoerce(directory):
+    path = FilePath(directory)
+    if not path.isdir():
+        raise ValueError("%r is not a directory")
+    return path
+
+
+class BenchmarkOptions(Options):
+    optParameters = [
+        ('host', 'h', 'localhost',
+         'Hostname or IPv4 address on which a CalendarServer is listening'),
+        ('port', 'p', 8008,
+         'Port number on which a CalendarServer is listening', portCoerce),
+        ('log-directory', 'd', None,
+         'Logs directory of the CalendarServer being benchmarked (if and only '
+         'if the CalendarServer is on the same host as this benchmark process)',
+         logsCoerce),
+        ('label', 'l', 'A descriptive string to attach to the output filename.'),
+        ]
+
+    optFlags = [
+        ('debug', None, 'Enable various debugging helpers'),
+        ]
+
+    def parseArgs(self, *benchmarks):
+        self['benchmarks'] = benchmarks
+        if not self['benchmarks']:
+            raise UsageError("Specify at least one benchmark")
+
+
 def main():
     from twisted.python.log import err
-    from twisted.python.failure import startDebugMode
-    startDebugMode()
+
+    options = BenchmarkOptions()
+    try:
+        options.parseOptions(sys.argv[1:])
+    except UsageError, e:
+        print e
+        return 1
+
+    if options['debug']:
+        from twisted.python.failure import startDebugMode
+        startDebugMode()
+
     d = benchmark(
-        sys.argv[1], sys.argv[2],
-        [(arg, namedAny(arg).measure) for arg in sys.argv[3:]])
+        options['host'], options['port'],
+        options['log-directory'], options['label'],
+        [(arg, namedAny(arg).measure) for arg in options['benchmarks']])
     d.addErrback(err)
-    d.addCallback(lambda ign: reactor.stop())
+    reactor.callWhenRunning(d.addCallback, lambda ign: reactor.stop())
     reactor.run()

Modified: CalendarServer/branches/generic-sqlstore/contrib/performance/event.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/event.py	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/event.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -90,10 +90,8 @@
 
 
 @inlineCallbacks
-def measure(dtrace, attendeeCount, samples):
+def measure(host, port, dtrace, attendeeCount, samples):
     user = password = "user01"
-    host = "localhost"
-    port = 8008
     root = "/"
     principal = "/"
     calendar = "event-creation-benchmark"

Copied: CalendarServer/branches/generic-sqlstore/contrib/performance/sample.sh (from rev 6187, CalendarServer/trunk/contrib/performance/sample.sh)
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/sample.sh	                        (rev 0)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/sample.sh	2010-08-26 14:07:16 UTC (rev 6188)
@@ -0,0 +1,39 @@
+#!/bin/bash -x
+
+set -e
+
+BACKENDS="filesystem postgresql"
+
+SOURCE=~/Projects/CalendarServer/trunk
+BENCHMARKS="vfreebusy event"
+ADDURL=http://localhost:8000/result/add/
+export PYTHONPATH=$PYTHONPATH:$SOURCE/../Twisted
+
+REV=$1
+
+pushd $SOURCE
+svn up -r$REV .
+python setup.py build_ext -i
+popd
+
+for backend in $BACKENDS; do
+  ./setbackend $SOURCE/conf/caldavd-test.plist $backend > $SOURCE/conf/caldavd-dev.plist
+  pushd $SOURCE
+  ./run -k || true
+  rm -rf data/
+  ./run -d -n
+  popd
+  sleep 5
+  ./benchmark --label r$REV-$backend $BENCHMARKS
+  data=`echo -n r$REV*`
+  for p in 1 9 81; do
+    for b in $BENCHMARKS; do
+      ./upload \
+          --url $ADDURL --revision $REV \
+          --revision-date "`./svn-committime $SOURCE`" --environment nmosbuilder \
+          --backend $backend --statistic "$data,$b,$p,urlopen time"
+    done
+  done
+
+  mv $data old-results/
+done

Copied: CalendarServer/branches/generic-sqlstore/contrib/performance/setbackend (from rev 6187, CalendarServer/trunk/contrib/performance/setbackend)
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/setbackend	                        (rev 0)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/setbackend	2010-08-26 14:07:16 UTC (rev 6188)
@@ -0,0 +1,4 @@
+#!/usr/bin/python
+
+from setbackend import main
+raise SystemExit(main())

Copied: CalendarServer/branches/generic-sqlstore/contrib/performance/setbackend.py (from rev 6187, CalendarServer/trunk/contrib/performance/setbackend.py)
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/setbackend.py	                        (rev 0)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/setbackend.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -0,0 +1,25 @@
+import sys
+from xml.etree import ElementTree
+from xml.etree import ElementPath
+
+def main():
+    conf = ElementTree.parse(file(sys.argv[1]))
+    if sys.argv[2] == 'postgresql':
+        value = 'true'
+    elif sys.argv[2] == 'filesystem':
+        value = 'false'
+    else:
+        raise RuntimeError("Don't know what to do with %r" % (sys.argv[2],))
+    replace(conf.getiterator(), value)
+    conf.write(sys.stdout)
+
+
+def replace(elements, value):
+    found = False
+    for ele in elements:
+        if found:
+            ele.tag = value
+            return
+        if ele.tag == 'key' and ele.text == 'UseDatabase':
+            found = True
+    raise RuntimeError("Failed to find <key>UseDatabase</key>")

Copied: CalendarServer/branches/generic-sqlstore/contrib/performance/svn-committime (from rev 6187, CalendarServer/trunk/contrib/performance/svn-committime)
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/svn-committime	                        (rev 0)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/svn-committime	2010-08-26 14:07:16 UTC (rev 6188)
@@ -0,0 +1,6 @@
+#!/usr/bin/python
+
+import sys, datetime
+import pysvn
+print datetime.datetime.fromtimestamp(pysvn.Client().info(sys.argv[1])['commit_time'])
+

Copied: CalendarServer/branches/generic-sqlstore/contrib/performance/svn-revno (from rev 6187, CalendarServer/trunk/contrib/performance/svn-revno)
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/svn-revno	                        (rev 0)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/svn-revno	2010-08-26 14:07:16 UTC (rev 6188)
@@ -0,0 +1,5 @@
+#!/usr/bin/python
+
+import sys
+import pysvn
+print pysvn.Client().info(sys.argv[1])['revision'].number

Copied: CalendarServer/branches/generic-sqlstore/contrib/performance/upload (from rev 6187, CalendarServer/trunk/contrib/performance/upload)
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/upload	                        (rev 0)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/upload	2010-08-26 14:07:16 UTC (rev 6188)
@@ -0,0 +1,3 @@
+#!/usr/bin/python
+from upload import main
+raise SystemExit(main())

Copied: CalendarServer/branches/generic-sqlstore/contrib/performance/upload.py (from rev 6187, CalendarServer/trunk/contrib/performance/upload.py)
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/upload.py	                        (rev 0)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/upload.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -0,0 +1,100 @@
+import sys
+import pickle
+
+from urllib import urlencode
+from datetime import datetime
+
+from twisted.python.log import err
+from twisted.python.usage import UsageError, Options
+from twisted.internet import reactor
+from twisted.web.client import Agent
+
+from stats import median, mad
+from benchlib import select
+from httpclient import StringProducer, readBody
+
+
+class UploadOptions(Options):
+    optParameters = [
+        ('url', None, None,
+         'Location of Codespeed server to which to upload.'),
+        ('project', None, 'CalendarServer',
+         'Name of the project to which the data relates '
+         '(as recognized by the Codespeed server)'),
+        ('revision', None, None,
+         'Revision number of the code which produced this data.'),
+        ('revision-date', None, None,
+         'Timestamp at which the specified revision was created.'),
+        ('environment', None, None,
+         'Name of the environment in which the data was produced.'),
+        ('statistic', None, None,
+         'Identifier for the file/benchmark/parameter'),
+        ('backend', None, None,
+         'Which storage backend produced this data.'),
+        ]
+
+    def postOptions(self):
+        assert self['url']
+        assert self['backend'] in ('filesystem', 'postgresql')
+
+
+
+def upload(reactor, url, project, revision, revision_date, benchmark,
+           executable, environment, result_value, result_date, std_dev,
+           max_value, min_value):
+    data = {
+        'commitid': str(revision),
+        'revision_date': revision_date,
+        'project': project,
+        'benchmark': benchmark,
+        'environment': environment,
+        'executable': executable,
+        'result_value': str(result_value),
+        'result_date': result_date,
+        'std_dev': str(std_dev),
+        'max': str(max_value),
+        'min': str(min_value),
+        }
+    agent = Agent(reactor)
+    d = agent.request('POST', url, None, StringProducer(urlencode(data)))
+    def check(response):
+        d = readBody(response)
+        def read(body):
+            print 'body', repr(body)
+            if response.code != 200:
+                raise Exception("Upload failed: %r" % (response.code,))
+        d.addCallback(read)
+        return d
+    d.addCallback(check)
+    return d
+
+
+def main():
+    options = UploadOptions()
+    try:
+        options.parseOptions(sys.argv[1:])
+    except UsageError, e:
+        print e
+        return 1
+
+    fname, benchmark, param, statistic = options['statistic'].split(',')
+    stat, samples = select(
+        pickle.load(file(fname)), benchmark, param, statistic)
+
+    d = upload(
+        reactor,
+        url=options['url'],
+        project=options['project'],
+        revision=options['revision'],
+        revision_date=options['revision-date'],
+        benchmark='%s-%s-%s' % (benchmark, param, statistic),
+        executable='%s-backend' % (options['backend'],),
+        environment=options['environment'],
+        result_value=median(samples),
+        result_date=datetime.now(),
+        std_dev=mad(samples),  # Not really!
+        max_value=max(samples),
+        min_value=min(samples))
+    d.addErrback(err, "Upload failed")
+    reactor.callWhenRunning(d.addCallback, lambda ign: reactor.stop())
+    reactor.run()

Modified: CalendarServer/branches/generic-sqlstore/contrib/performance/vfreebusy.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/contrib/performance/vfreebusy.py	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/contrib/performance/vfreebusy.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -6,8 +6,6 @@
 from uuid import uuid4
 from datetime import datetime, timedelta
 
-from protocol.url import URL
-
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.internet import reactor
 from twisted.web.client import Agent
@@ -97,10 +95,8 @@
 
 
 @inlineCallbacks
-def measure(dtrace, events, samples):
+def measure(host, port, dtrace, events, samples):
     user = password = "user01"
-    host = "localhost"
-    port = 8008
     root = "/"
     principal = "/"
     calendar = "vfreebusy-benchmark"
@@ -114,19 +110,20 @@
     agent = AuthHandlerAgent(Agent(reactor), authinfo)
 
     # First set things up
-    account = yield initialize(agent, host, port, user, password, root, principal, calendar)
+    account = yield initialize(
+        agent, host, port, user, password, root, principal, calendar)
 
     base = "/calendars/users/%s/%s/foo-%%d.ics" % (user, calendar)
     for i, cal in enumerate(makeEvents(events)):
-        yield account.writeData(URL(base % (i,)), cal, "text/calendar")
+        yield account.writeData(base % (i,), cal, "text/calendar")
 
     method = 'POST'
-    uri = 'http://localhost:8008/calendars/__uids__/%s/outbox/' % (user,)
+    uri = 'http://%s:%d/calendars/__uids__/%s/outbox/' % (host, port, user)
     headers = Headers({"content-type": ["text/calendar"]})
     body = StringProducer(vfreebusy)
 
     samples = yield sample(
-        dtrace, samples, 
+        dtrace, samples,
         agent, lambda: (method, uri, headers, body))
     returnValue(samples)
 

Modified: CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/aggregate.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/aggregate.py	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/aggregate.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -236,6 +236,14 @@
         service = self.serviceForRecordType(recordType)
         return service.destroyRecord(recordType, guid=guid)
 
+    def setRealm(self, realmName):
+        """
+        Set a new realm name for this and nested services
+        """
+        self.realmName = realmName
+        for service in self._recordTypes.values():
+            service.setRealm(realmName)
+
 class DuplicateRecordTypeError(DirectoryError):
     """
     Duplicate record type.

Modified: CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/calendar.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/calendar.py	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/calendar.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -248,11 +248,11 @@
         name = record.uid
 
         if record is None:
-            self.log_msg("No directory record with GUID %r" % (name,))
+            log.debug("No directory record with GUID %r" % (name,))
             return None
 
         if not record.enabledForCalendaring:
-            self.log_msg("Directory record %r is not enabled for calendaring" % (record,))
+            log.debug("Directory record %r is not enabled for calendaring" % (record,))
             return None
 
         assert len(name) > 4, "Directory record has an invalid GUID: %r" % (name,)

Modified: CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/directory.py	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/directory.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -83,6 +83,9 @@
     # Needed by twistedcaldav.directorybackedaddressbook
     liveQuery = False
 
+    def setRealm(self, realmName):
+        self.realmName = realmName
+
     def available(self):
         """
         By default, the directory is available.  This may return a boolean or a

Modified: CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/idirectory.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/idirectory.py	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/idirectory.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -87,7 +87,13 @@
             match the given fields.
         """
 
+    def setRealm(realmName):
+        """
+        Set a new realm name for this (and nested services if any)
 
+        @param realmName: the realm name this service should use.
+        """
+
 class IDirectoryRecord(Interface):
     """
     Directory Record

Modified: CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/test/test_aggregate.py
===================================================================
--- CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/test/test_aggregate.py	2010-08-26 13:35:58 UTC (rev 6187)
+++ CalendarServer/branches/generic-sqlstore/twistedcaldav/directory/test/test_aggregate.py	2010-08-26 14:07:16 UTC (rev 6188)
@@ -68,3 +68,13 @@
         augment.AugmentService = augment.AugmentXMLDB(xmlFiles=(augmentsFile.path,))
 
         return AggregateDirectoryService((xmlService,))
+
+    def test_setRealm(self):
+        """
+        setRealm gets propagated to nested services
+        """
+        aggregatedService = self.service()
+        aggregatedService.setRealm("foo.example.com")
+        for service in aggregatedService._recordTypes.values():
+            self.assertEquals("foo.example.com", service.realmName)
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100826/ae3c5a8c/attachment-0001.html>


More information about the calendarserver-changes mailing list