[CalendarServer-changes] [11667] CalendarServer/branches/users/gaya/sharedgroupfixes

source_changes at macosforge.org source_changes at macosforge.org
Wed Sep 11 10:36:20 PDT 2013


Revision: 11667
          http://trac.calendarserver.org//changeset/11667
Author:   gaya at apple.com
Date:     2013-09-11 10:36:20 -0700 (Wed, 11 Sep 2013)
Log Message:
-----------
merge in through r11666

Revision Links:
--------------
    http://trac.calendarserver.org//changeset/11666

Modified Paths:
--------------
    CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/provision/root.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tap/caldav.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/agent.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/dbinspect.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/gateway.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/test/test_agent.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/util.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/testserver
    CalendarServer/branches/users/gaya/sharedgroupfixes/twext/internet/sendfdport.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/twext/web2/channel/http.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/twext/web2/test/test_http.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/directory/directory.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/directory/test/test_directory.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/stdconfig.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/scheduling/processing.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/scheduling/test/test_implicit.py
    CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/common/datastore/sql.py

Property Changed:
----------------
    CalendarServer/branches/users/gaya/sharedgroupfixes/


Property changes on: CalendarServer/branches/users/gaya/sharedgroupfixes
___________________________________________________________________
Modified: svn:mergeinfo
   - /CalDAVTester/trunk:11193-11198
/CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/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/release/CalendarServer-4.3-dev:10180-10190,10192
/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11612
/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/pods:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
/CalendarServer/branches/users/cdaboo/pycard:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
/CalendarServer/branches/users/cdaboo/timezones:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
/CalendarServer/branches/users/glyph/conn-limit:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/dalify:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
/CalendarServer/branches/users/glyph/deploybuild:7563-7572
/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
/CalendarServer/branches/users/glyph/disable-quota:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
/CalendarServer/branches/users/glyph/hang-fix:11465-11491
/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
/CalendarServer/branches/users/glyph/linux-tests:6893-6900
/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
/CalendarServer/branches/users/glyph/new-export:7444-7485
/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
/CalendarServer/branches/users/glyph/oracle:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
/CalendarServer/branches/users/glyph/other-html:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
/CalendarServer/branches/users/glyph/q:9560-9688
/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
/CalendarServer/branches/users/glyph/quota:7604-7637
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
/CalendarServer/branches/users/glyph/sharedpool:6490-6550
/CalendarServer/branches/users/glyph/sharing-api:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
/CalendarServer/branches/users/glyph/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
/CalendarServer/branches/users/sagen/applepush:8126-8184
/CalendarServer/branches/users/sagen/inboxitems:7380-7381
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/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/sagen/testing:10827-10851,10853-10855
/CalendarServer/branches/users/wsanchez/transations:5515-5593
/CalendarServer/trunk:11632-11645
   + /CalDAVTester/trunk:11193-11198
/CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/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/release/CalendarServer-4.3-dev:10180-10190,10192
/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11612
/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/pods:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
/CalendarServer/branches/users/cdaboo/pycard:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
/CalendarServer/branches/users/cdaboo/timezones:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
/CalendarServer/branches/users/glyph/conn-limit:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/dalify:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
/CalendarServer/branches/users/glyph/deploybuild:7563-7572
/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
/CalendarServer/branches/users/glyph/disable-quota:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
/CalendarServer/branches/users/glyph/hang-fix:11465-11491
/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
/CalendarServer/branches/users/glyph/linux-tests:6893-6900
/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
/CalendarServer/branches/users/glyph/new-export:7444-7485
/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
/CalendarServer/branches/users/glyph/oracle:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
/CalendarServer/branches/users/glyph/other-html:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
/CalendarServer/branches/users/glyph/q:9560-9688
/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
/CalendarServer/branches/users/glyph/quota:7604-7637
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
/CalendarServer/branches/users/glyph/sharedpool:6490-6550
/CalendarServer/branches/users/glyph/sharing-api:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
/CalendarServer/branches/users/glyph/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
/CalendarServer/branches/users/sagen/applepush:8126-8184
/CalendarServer/branches/users/sagen/inboxitems:7380-7381
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/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/sagen/testing:10827-10851,10853-10855
/CalendarServer/branches/users/wsanchez/transations:5515-5593
/CalendarServer/trunk:11632-11666

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/provision/root.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/provision/root.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/provision/root.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -94,15 +94,7 @@
             from twext.web2.filter import gzip
             self.contentFilters.append((gzip.gzipfilter, True))
 
-        if not config.EnableKeepAlive:
-            def addConnectionClose(request, response):
-                response.headers.setHeader("connection", ("close",))
-                if request.chanRequest is not None:
-                    request.chanRequest.channel.setReadPersistent(False)
-                return response
-            self.contentFilters.append((addConnectionClose, True))
 
-
     def deadProperties(self):
         if not hasattr(self, "_dead_properties"):
             # Get the property store from super

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tap/caldav.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tap/caldav.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -58,13 +58,15 @@
 from twext.internet.ssl import ChainingOpenSSLContextFactory
 from twext.internet.tcp import MaxAcceptTCPServer, MaxAcceptSSLServer
 from twext.internet.fswatch import DirectoryChangeListener, IDirectoryChangeListenee
-from twext.web2.channel.http import LimitingHTTPFactory, SSLRedirectRequest
+from twext.web2.channel.http import LimitingHTTPFactory, SSLRedirectRequest, \
+    HTTPChannel
 from twext.web2.metafd import ConnectionLimiter, ReportingHTTPService
 from twext.enterprise.ienterprise import POSTGRES_DIALECT
 from twext.enterprise.ienterprise import ORACLE_DIALECT
 from twext.enterprise.adbapi2 import ConnectionPool
+from twext.enterprise.queue import NonPerformingQueuer
+from twext.enterprise.queue import PeerConnectionPool
 from twext.enterprise.queue import WorkerFactory as QueueWorkerFactory
-from twext.enterprise.queue import PeerConnectionPool
 
 from txdav.common.datastore.sql_tables import schema
 from txdav.common.datastore.upgrade.sql.upgrade import (
@@ -242,14 +244,15 @@
         self.logRotateLength = logRotateLength
         self.logMaxFiles = logMaxFiles
 
+
     def setServiceParent(self, app):
         MultiService.setServiceParent(self, app)
 
         if self.logEnabled:
             errorLogFile = LogFile.fromFullPath(
                 self.logPath,
-                rotateLength = self.logRotateLength,
-                maxRotatedFiles = self.logMaxFiles
+                rotateLength=self.logRotateLength,
+                maxRotatedFiles=self.logMaxFiles
             )
             errorLogObserver = FileLogObserver(errorLogFile).emit
 
@@ -977,6 +980,13 @@
             def requestFactory(*args, **kw):
                 return SSLRedirectRequest(site=underlyingSite, *args, **kw)
 
+        # Setup HTTP connection behaviors
+        HTTPChannel.allowPersistentConnections = config.EnableKeepAlive
+        HTTPChannel.betweenRequestsTimeOut = config.PipelineIdleTimeOut
+        HTTPChannel.inputTimeOut = config.IncomingDataTimeOut
+        HTTPChannel.idleTimeOut = config.IdleConnectionTimeOut
+        HTTPChannel.closeTimeOut = config.CloseConnectionTimeOut
+
         # Add the Strict-Transport-Security header to all secured requests
         # if enabled.
         if config.StrictTransportSecuritySeconds:
@@ -990,6 +1000,7 @@
                             "max-age={max_age:d}"
                             .format(max_age=config.StrictTransportSecuritySeconds))
                     return response
+                responseFilter.handleErrors = True
                 request.addResponseFilter(responseFilter)
                 return request
 
@@ -1266,8 +1277,9 @@
         Create an agent service which listens for configuration requests
         """
 
-        # Don't use memcached -- calendar server might take it away at any
-        # moment
+        # Don't use memcached initially -- calendar server might take it away at
+        # any moment.  However, when we run a command through the gateway, it
+        # will conditionally set ClientEnabled at that time.
         def agentPostUpdateHook(configDict, reloading=False):
             configDict.Memcached.Pools.Default.ClientEnabled = False
 
@@ -1285,6 +1297,8 @@
                 dataStoreWatcher = DirectoryChangeListener(reactor,
                     config.DataRoot, DataStoreMonitor(reactor, storageService))
                 dataStoreWatcher.startListening()
+            if store is not None:
+                store.queuer = NonPerformingQueuer()
             return makeAgentService(store)
 
         uid, gid = getSystemIDs(config.UserName, config.GroupName)
@@ -2419,6 +2433,7 @@
     return uid, gid
 
 
+
 class DataStoreMonitor(object):
     implements(IDirectoryChangeListenee)
 
@@ -2430,18 +2445,21 @@
         self._reactor = reactor
         self._storageService = storageService
 
+
     def disconnected(self):
         self._storageService.hardStop()
         self._reactor.stop()
 
+
     def deleted(self):
         self._storageService.hardStop()
         self._reactor.stop()
 
+
     def renamed(self):
         self._storageService.hardStop()
         self._reactor.stop()
 
+
     def connectionLost(self, reason):
         pass
-

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/agent.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/agent.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/agent.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -243,7 +243,8 @@
         log.warn("Agent inactive; shutting down")
         reactor.stop()
 
-    inactivityDetector = InactivityDetector(reactor, 60 * 10, becameInactive)
+    inactivityDetector = InactivityDetector(reactor,
+        config.AgentInactivityTimeoutSeconds, becameInactive)
     root = Resource()
     root.putChild("gateway", AgentGatewayResource(store,
         davRootResource, directory, inactivityDetector))
@@ -278,8 +279,9 @@
         self._timeoutSeconds = timeoutSeconds
         self._becameInactive = becameInactive
 
-        self._delayedCall = self._reactor.callLater(self._timeoutSeconds,
-            self._inactivityThresholdReached)
+        if self._timeoutSeconds > 0:
+            self._delayedCall = self._reactor.callLater(self._timeoutSeconds,
+                self._inactivityThresholdReached)
 
 
     def _inactivityThresholdReached(self):
@@ -295,19 +297,21 @@
         Call this to let the InactivityMonitor that there has been activity.
         It will reset the timeout.
         """
-        if self._delayedCall.active():
-            self._delayedCall.reset(self._timeoutSeconds)
-        else:
-            self._delayedCall = self._reactor.callLater(self._timeoutSeconds,
-                self._inactivityThresholdReached)
+        if self._timeoutSeconds > 0:
+            if self._delayedCall.active():
+                self._delayedCall.reset(self._timeoutSeconds)
+            else:
+                self._delayedCall = self._reactor.callLater(self._timeoutSeconds,
+                    self._inactivityThresholdReached)
 
 
     def stop(self):
         """
         Cancels the delayed call
         """
-        if self._delayedCall.active():
-            self._delayedCall.cancel()
+        if self._timeoutSeconds > 0:
+            if self._delayedCall.active():
+                self._delayedCall.cancel()
 
 
 

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/dbinspect.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/dbinspect.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/dbinspect.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -22,8 +22,6 @@
 of simple commands.
 """
 
-from caldavclientlibrary.admin.xmlaccounts.recordtypes import recordType_users, \
-    recordType_locations, recordType_resources, recordType_groups
 from calendarserver.tools import tables
 from calendarserver.tools.cmdline import utilityMain
 from pycalendar.datetime import PyCalendarDateTime
@@ -38,6 +36,7 @@
 from twistedcaldav.config import config
 from twistedcaldav.datafilters.peruserdata import PerUserDataFilter
 from twistedcaldav.directory import calendaruserproxy
+from twistedcaldav.directory.directory import DirectoryService
 from twistedcaldav.query import calendarqueryfilter
 from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
 from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
@@ -104,13 +103,13 @@
     except (ValueError, TypeError):
         pass
 
-    record = txn.directoryService().recordWithShortName(recordType_users, value)
+    record = txn.directoryService().recordWithShortName(DirectoryService.recordType_users, value)
     if record is None:
-        record = txn.directoryService().recordWithShortName(recordType_locations, value)
+        record = txn.directoryService().recordWithShortName(DirectoryService.recordType_locations, value)
     if record is None:
-        record = txn.directoryService().recordWithShortName(recordType_resources, value)
+        record = txn.directoryService().recordWithShortName(DirectoryService.recordType_resources, value)
     if record is None:
-        record = txn.directoryService().recordWithShortName(recordType_groups, value)
+        record = txn.directoryService().recordWithShortName(DirectoryService.recordType_groups, value)
     return record.guid if record else None
 
 

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/gateway.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/gateway.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/gateway.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -30,7 +30,7 @@
 
 from calendarserver.tools.util import (
     principalForPrincipalID, proxySubprincipal, addProxy, removeProxy,
-    ProxyError, ProxyWarning
+    ProxyError, ProxyWarning, autoDisableMemcached
 )
 from calendarserver.tools.principals import getProxies, setProxies, updateRecord
 from calendarserver.tools.purge import WorkerService, PurgeOldEventsService, DEFAULT_BATCH_SIZE, DEFAULT_RETAIN_DAYS
@@ -188,6 +188,22 @@
 
     @inlineCallbacks
     def run(self):
+
+        # This method can be called as the result of an agent request.  We
+        # check to see if memcached is there for each call because the server
+        # could have stopped/started since the last time.
+
+        for pool in config.Memcached.Pools.itervalues():
+            pool.ClientEnabled = True
+        autoDisableMemcached(config)
+
+        from twistedcaldav.directory import calendaruserproxy
+        if calendaruserproxy.ProxyDBService is not None:
+            # Reset the proxy db memcacher because memcached may have come or
+            # gone since the last time through here.
+            # TODO: figure out a better way to do this
+            calendaruserproxy.ProxyDBService._memcacher._memcacheProtocol = None
+
         try:
             for command in self.commands:
                 commandName = command['command']

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/test/test_agent.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/test/test_agent.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/test/test_agent.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -145,6 +145,9 @@
 
             id.stop()
 
+            # Verify a timeout of 0 does not ever fire
+            id = InactivityDetector(clock, 0, becameInactive)
+            self.assertEquals(clock.getDelayedCalls(), [])
 
 
     class FakeRequest(object):

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/util.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/util.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/calendarserver/tools/util.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -235,23 +235,21 @@
 
 def autoDisableMemcached(config):
     """
-    If memcached is not running, set config.Memcached.ClientEnabled to False
+    Set ClientEnabled to False for each pool whose memcached is not running
     """
 
-    if not config.Memcached.Pools.Default.ClientEnabled:
-        return
+    for pool in config.Memcached.Pools.itervalues():
+        if pool.ClientEnabled:
+            try:
+                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+                s.connect((pool.BindAddress, pool.Port))
+                s.close()
 
-    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            except socket.error:
+                pool.ClientEnabled = False
 
-    try:
-        s.connect((config.Memcached.Pools.Default.BindAddress, config.Memcached.Pools.Default.Port))
-        s.close()
 
-    except socket.error:
-        config.Memcached.Pools.Default.ClientEnabled = False
 
-
-
 def setupMemcached(config):
     #
     # Connect to memcached

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/testserver
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/testserver	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/testserver	2013-09-11 17:36:20 UTC (rev 11667)
@@ -28,6 +28,8 @@
 printres="";
 subdir="";
 random="--random";
+seed="";
+ssl="";
 
 usage ()
 {
@@ -40,13 +42,15 @@
   echo "        -r  Print request and response";
   echo "        -s  Set the serverinfo.xml";
   echo "        -t  Set the CalDAVTester directory";
+  echo "        -x  Random seed to use.";
   echo "        -v  Verbose.";
+  echo "        -z  Use SSL.";
 
   if [ "${1-}" == "-" ]; then return 0; fi;
   exit 64;
 }
 
-while getopts 'hvrot:s:d:' option; do
+while getopts 'hvrozt:s:d:x:' option; do
   case "$option" in 
     '?') usage; ;;
     'h') usage -; exit 0; ;;
@@ -56,6 +60,8 @@
     'r') printres="--always-print-request --always-print-response"; ;;
     'v') verbose="v"; ;;
     'o') random=""; ;;
+    'x') seed="--random-seed ${OPTARG}"; ;;
+    'z') ssl="--ssl"; ;;
   esac;
 done;
 
@@ -71,5 +77,5 @@
 
 source "${wd}/support/shell.sh";
 
-cd "${cdt}" && "${python}" testcaldav.py ${random} --print-details-onfail ${printres} -s "${serverinfo}" ${subdir} "$@";
+cd "${cdt}" && "${python}" testcaldav.py ${random} ${seed} ${ssl} --print-details-onfail ${printres} -s "${serverinfo}" ${subdir} "$@";
 

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/twext/internet/sendfdport.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/twext/internet/sendfdport.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/twext/internet/sendfdport.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -153,6 +153,10 @@
                     self.outgoingSocketQueue.insert(0, (skt, desc))
                     return
                 raise
+
+            # Always close the socket on this end
+            skt.close()
+
         if not self.outgoingSocketQueue:
             self.stopWriting()
 
@@ -185,7 +189,7 @@
         than the somewhat more abstract language that would be accurate.
     """
 
-    def initialStatus():
+    def initialStatus(): #@NoSelf
         """
         A new socket was created and added to the dispatcher.  Compute an
         initial value for its status.
@@ -193,8 +197,7 @@
         @return: the new status.
         """
 
-
-    def newConnectionStatus(previousStatus):
+    def newConnectionStatus(previousStatus): #@NoSelf
         """
         A new connection was sent to a given socket.  Compute its status based
         on the previous status of that socket.
@@ -205,8 +208,7 @@
         @return: the socket's status after incrementing its outstanding work.
         """
 
-
-    def statusFromMessage(previousStatus, message):
+    def statusFromMessage(previousStatus, message): #@NoSelf
         """
         A status message was received by a worker.  Convert the previous status
         value (returned from L{newConnectionStatus}, L{initialStatus}, or
@@ -412,4 +414,3 @@
         """
         self.statusQueue.append(statusMessage)
         self.startWriting()
-

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/twext/web2/channel/http.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/twext/web2/channel/http.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/twext/web2/channel/http.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -726,6 +726,10 @@
     betweenRequestsTimeOut = 15
     # Timeout between lines or bytes while reading a request
     inputTimeOut = 60 * 4
+    # Timeout between end of request read and end of response write
+    idleTimeOut = 60 * 5
+    # Timeout when closing non-persistent connection
+    closeTimeOut = 20
 
     # maximum length of headers (10KiB)
     maxHeaderLength = 10240
@@ -744,7 +748,7 @@
     _readLost = False
     _writeLost = False
     
-    _lingerTimer = None
+    _abortTimer = None
     chanRequest = None
 
     def _callLater(self, secs, fun):
@@ -823,10 +827,10 @@
         self.chanRequest = None
         self.setLineMode()
         
-        # Disable the idle timeout, in case this request takes a long
+        # Set an idle timeout, in case this request takes a long
         # time to finish generating output.
         if len(self.requests) > 0:
-            self.setTimeout(None)
+            self.setTimeout(self.idleTimeOut)
         
     def _startNextRequest(self):
         # notify next request, if present, it can start writing
@@ -881,57 +885,29 @@
             # incoming requests.
             self._callLater(0, self._startNextRequest)
         else:
-            self.lingeringClose()
+            # Set an abort timer in case an orderly close hangs
+            self.setTimeout(None)
+            self._abortTimer = reactor.callLater(self.closeTimeOut, self._abortTimeout)
+            #reactor.callLater(0.1, self.transport.loseConnection)
+            self.transport.loseConnection()
 
     def timeoutConnection(self):
         #log.info("Timing out client: %s" % str(self.transport.getPeer()))
+        # Set an abort timer in case an orderly close hangs
+        self._abortTimer = reactor.callLater(self.closeTimeOut, self._abortTimeout)
         policies.TimeoutMixin.timeoutConnection(self)
 
-    def lingeringClose(self):
-        """
-        This is a bit complicated. This process is necessary to ensure proper
-        workingness when HTTP pipelining is in use.
+    def _abortTimeout(self):
+        log.error("Connection aborted - took too long to close: {c}", c=str(self.transport.getPeer()))
+        self._abortTimer = None
+        self.transport.abortConnection()
 
-        Here is what it wants to do:
-
-            1.  Finish writing any buffered data, then close our write side.
-                While doing so, read and discard any incoming data.
-
-            2.  When that happens (writeConnectionLost called), wait up to 20
-                seconds for the remote end to close their write side (our read
-                side).
-
-            3.
-                - If they do (readConnectionLost called), close the socket,
-                  and cancel the timeout.
-
-                - If that doesn't happen, the timer fires, and makes the
-                  socket close anyways.
-        """
-        
-        # Close write half
-        self.transport.loseWriteConnection()
-        
-        # Throw out any incoming data
-        self.dataReceived = self.lineReceived = lambda *args: None
-        self.transport.resumeProducing()
-
-    def writeConnectionLost(self):
-        # Okay, all data has been written
-        # In 20 seconds, actually close the socket
-        self._lingerTimer = reactor.callLater(20, self._lingerClose)
-        self._writeLost = True
-        
-    def _lingerClose(self):
-        self._lingerTimer = None
-        self.transport.loseConnection()
-        
     def readConnectionLost(self):
         """Read connection lost"""
         # If in the lingering-close state, lose the socket.
-        if self._lingerTimer:
-            self._lingerTimer.cancel()
-            self._lingerTimer = None
+        if self._abortTimer:
+            self._abortTimer.cancel()
+            self._abortTimer = None
             self.transport.loseConnection()
             return
         

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/twext/web2/test/test_http.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/twext/web2/test/test_http.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/twext/web2/test/test_http.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -14,7 +14,7 @@
 from twisted.internet.defer import waitForDeferred, deferredGenerator
 from twisted.protocols import loopback
 from twisted.python import util, runtime
-from twext.web2.channel.http import SSLRedirectRequest, HTTPFactory
+from twext.web2.channel.http import SSLRedirectRequest, HTTPFactory, HTTPChannel
 from twisted.internet.task import deferLater
 
 
@@ -319,6 +319,10 @@
         self.loseConnection()
 
 
+    def abortConnection(self):
+        self.aborted = True
+
+
     def getHost(self):
         """
         Synthesize a slightly more realistic 'host' thing.
@@ -409,6 +413,13 @@
 
     requestClass = TestRequest
 
+    def setUp(self):
+        super(HTTPTests, self).setUp()
+
+        # We always need this set to True - previous tests may have changed it
+        HTTPChannel.allowPersistentConnections = True
+
+
     def connect(self, logFile=None, **protocol_kwargs):
         cxn = TestConnection()
 
@@ -850,6 +861,42 @@
         self.compareResult(cxn, cmds, data)
         return deferLater(reactor, 0.5, self.assertDone, cxn) # Wait for timeout
 
+    def testTimeout_idleRequest(self):
+        cxn = self.connect(idleTimeOut=0.3)
+        cmds = [[]]
+        data = ""
+
+        cxn.client.write("GET / HTTP/1.1\r\n\r\n")
+        cmds[0] += [('init', 'GET', '/', (1, 1), 0, ()),
+                    ('contentComplete',)]
+        self.compareResult(cxn, cmds, data)
+
+        return deferLater(reactor, 0.5, self.assertDone, cxn) # Wait for timeout
+
+    def testTimeout_abortRequest(self):
+        cxn = self.connect(allowPersistentConnections=False, closeTimeOut=0.3)
+        cxn.client.transport.loseConnection = lambda : None
+        cmds = [[]]
+        data = ""
+
+        cxn.client.write("GET / HTTP/1.1\r\n\r\n")
+        cmds[0] += [('init', 'GET', '/', (1, 1), 0, ()),
+                    ('contentComplete',)]
+        self.compareResult(cxn, cmds, data)
+
+        response = TestResponse()
+        response.headers.setRawHeaders("Content-Length", ("0",))
+        cxn.requests[0].writeResponse(response)
+        response.finish()
+
+        data += "HTTP/1.1 200 OK\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"
+
+        self.compareResult(cxn, cmds, data)
+        def _check(cxn):
+            self.assertDone(cxn)
+            self.assertTrue(cxn.serverToClient.aborted)
+        return deferLater(reactor, 0.5, self.assertDone, cxn) # Wait for timeout
+
     def testConnectionCloseRequested(self):
         cxn = self.connect()
         cmds = [[]]
@@ -883,6 +930,26 @@
         self.compareResult(cxn, cmds, data)
         self.assertDone(cxn)
 
+    def testConnectionKeepAliveOff(self):
+        cxn = self.connect(allowPersistentConnections=False)
+        cmds = [[]]
+        data = ""
+
+        cxn.client.write("GET / HTTP/1.1\r\n\r\n")
+        cmds[0] += [('init', 'GET', '/', (1, 1), 0, ()),
+                    ('contentComplete',)]
+        self.compareResult(cxn, cmds, data)
+
+        response = TestResponse()
+        response.headers.setRawHeaders("Content-Length", ("0",))
+        cxn.requests[0].writeResponse(response)
+        response.finish()
+
+        data += "HTTP/1.1 200 OK\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"
+
+        self.compareResult(cxn, cmds, data)
+        self.assertDone(cxn)
+
     def testExtraCRLFs(self):
         cxn = self.connect()
         cmds = [[]]

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/directory/directory.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/directory/directory.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -813,7 +813,7 @@
             # populated the membership cache, and if so, return immediately
             if isPopulated:
                 self.log.info("Group membership cache is already populated")
-                returnValue((fast, 0))
+                returnValue((fast, 0, 0))
 
             # We don't care what others are doing right now, we need to update
             useLock = False
@@ -832,15 +832,21 @@
         else:
             self.log.info("Group membership snapshot file exists: %s" %
                 (membershipsCacheFile.path,))
-            previousMembers = pickle.loads(membershipsCacheFile.getContent())
             callGroupsChanged = True
+            try:
+                previousMembers = pickle.loads(membershipsCacheFile.getContent())
+            except:
+                self.log.warn("Could not parse snapshot; will regenerate cache")
+                fast = False
+                previousMembers = {}
+                callGroupsChanged = False
 
         if useLock:
             self.log.info("Attempting to acquire group membership cache lock")
             acquiredLock = (yield self.cache.acquireLock())
             if not acquiredLock:
                 self.log.info("Group membership cache lock held by another process")
-                returnValue((fast, 0))
+                returnValue((fast, 0, 0))
             self.log.info("Acquired lock")
 
         if not fast and self.useExternalProxies:
@@ -850,7 +856,11 @@
             if extProxyCacheFile.exists():
                 self.log.info("External proxies snapshot file exists: %s" %
                     (extProxyCacheFile.path,))
-                previousAssignments = pickle.loads(extProxyCacheFile.getContent())
+                try:
+                    previousAssignments = pickle.loads(extProxyCacheFile.getContent())
+                except:
+                    self.log.warn("Could not parse external proxies snapshot")
+                    previousAssignments = []
 
             if useLock:
                 yield self.cache.extendLock()

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/directory/test/test_directory.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/directory/test/test_directory.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/directory/test/test_directory.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -243,7 +243,7 @@
         # Prevent an update by locking the cache
         acquiredLock = (yield cache.acquireLock())
         self.assertTrue(acquiredLock)
-        self.assertEquals((False, 0), (yield updater.updateCache()))
+        self.assertEquals((False, 0, 0), (yield updater.updateCache()))
 
         # You can't lock when already locked:
         acquiredLockAgain = (yield cache.acquireLock())
@@ -667,7 +667,7 @@
         # as indicated by the return value for "fast".  Note that the cache
         # is already populated so updateCache( ) in fast mode will not do
         # anything, and numMembers will be 0.
-        fast, numMembers = (yield updater.updateCache(fast=True))
+        fast, numMembers, numChanged = (yield updater.updateCache(fast=True))
         self.assertEquals(fast, True)
         self.assertEquals(numMembers, 0)
 
@@ -678,61 +678,70 @@
         self.assertEquals(numChanged, 0)
 
         # Verify the snapshot contains the pickled dictionary we expect
+        expected = {
+            "46D9D716-CBEE-490F-907A-66FA6C3767FF":
+                set([
+                    u"00599DAF-3E75-42DD-9DB7-52617E79943F",
+                ]),
+            "5A985493-EE2C-4665-94CF-4DFEA3A89500":
+                set([
+                    u"non_calendar_group",
+                    u"recursive1_coasts",
+                    u"recursive2_coasts",
+                    u"both_coasts"
+                ]),
+            "6423F94A-6B76-4A3A-815B-D52CFD77935D":
+                set([
+                    u"left_coast",
+                    u"recursive1_coasts",
+                    u"recursive2_coasts",
+                    u"both_coasts"
+                ]),
+            "5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1":
+                set([
+                    u"left_coast",
+                    u"both_coasts"
+                ]),
+            "8B4288F6-CC82-491D-8EF9-642EF4F3E7D0":
+                set([
+                    u"non_calendar_group",
+                    u"left_coast",
+                    u"both_coasts"
+                ]),
+            "left_coast":
+                 set([
+                     u"both_coasts"
+                 ]),
+            "recursive1_coasts":
+                 set([
+                     u"recursive1_coasts",
+                     u"recursive2_coasts"
+                 ]),
+            "recursive2_coasts":
+                set([
+                    u"recursive1_coasts",
+                    u"recursive2_coasts"
+                ]),
+            "right_coast":
+                set([
+                    u"both_coasts"
+                ])
+        }
         members = pickle.loads(snapshotFile.getContent())
-        self.assertEquals(
-            members,
-            {
-                "46D9D716-CBEE-490F-907A-66FA6C3767FF":
-                    set([
-                        u"00599DAF-3E75-42DD-9DB7-52617E79943F",
-                    ]),
-                "5A985493-EE2C-4665-94CF-4DFEA3A89500":
-                    set([
-                        u"non_calendar_group",
-                        u"recursive1_coasts",
-                        u"recursive2_coasts",
-                        u"both_coasts"
-                    ]),
-                "6423F94A-6B76-4A3A-815B-D52CFD77935D":
-                    set([
-                        u"left_coast",
-                        u"recursive1_coasts",
-                        u"recursive2_coasts",
-                        u"both_coasts"
-                    ]),
-                "5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1":
-                    set([
-                        u"left_coast",
-                        u"both_coasts"
-                    ]),
-                "8B4288F6-CC82-491D-8EF9-642EF4F3E7D0":
-                    set([
-                        u"non_calendar_group",
-                        u"left_coast",
-                        u"both_coasts"
-                    ]),
-                "left_coast":
-                     set([
-                         u"both_coasts"
-                     ]),
-                "recursive1_coasts":
-                     set([
-                         u"recursive1_coasts",
-                         u"recursive2_coasts"
-                     ]),
-                "recursive2_coasts":
-                    set([
-                        u"recursive1_coasts",
-                        u"recursive2_coasts"
-                    ]),
-                "right_coast":
-                    set([
-                        u"both_coasts"
-                    ])
-            }
-        )
+        self.assertEquals(members, expected)
+        
+        # "Corrupt" the snapshot and verify it is regenerated properly
+        snapshotFile.setContent("xyzzy")
+        cache.delete("group-cacher-populated")
+        fast, numMembers, numChanged = (yield updater.updateCache(fast=True))
+        self.assertEquals(fast, False)
+        self.assertEquals(numMembers, 9)
+        self.assertEquals(numChanged, 9)
+        self.assertTrue(snapshotFile.exists())
+        members = pickle.loads(snapshotFile.getContent())
+        self.assertEquals(members, expected)
+        
 
-
     def test_autoAcceptMembers(self):
         """
         autoAcceptMembers( ) returns an empty list if no autoAcceptGroup is

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/stdconfig.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/twistedcaldav/stdconfig.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -825,7 +825,12 @@
                                    # connections used per worker process.
 
     "ListenBacklog": 2024,
-    "IdleConnectionTimeOut": 15,
+
+    "IncomingDataTimeOut": 60,          # Max. time between request lines
+    "PipelineIdleTimeOut": 15,          # Max. time between pipelined requests
+    "IdleConnectionTimeOut": 60 * 6,    # Max. time for response processing
+    "CloseConnectionTimeOut": 15,       # Max. time for client close
+
     "UIDReservationTimeOut": 30 * 60,
 
     "MaxMultigetWithDataHrefs": 5000,
@@ -996,6 +1001,10 @@
     # America/Los_Angeles.
     "DefaultTimezone" : "",
 
+    # After this many seconds of no admin requests, shutdown the agent.  Zero
+    # means no automatic shutdown.
+    "AgentInactivityTimeoutSeconds"  : 4 * 60 * 60,
+
     # These two aren't relative to ConfigRoot:
     "Includes": [], # Other plists to parse after this one
     "WritableConfigFile" : "", # which config file calendarserver_config should

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/scheduling/processing.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/scheduling/processing.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -359,7 +359,7 @@
             # refresh them. To prevent a race we need a lock.
             yield NamedLock.acquire(txn, "ImplicitUIDLock:%s" % (hashlib.md5(self.uid).hexdigest(),))
 
-            organizer_home = (yield txn.calendarHomeForUID(self.organizer_uid))
+            organizer_home = (yield txn.calendarHomeWithUID(self.organizer_uid))
             organizer_resource = (yield organizer_home.objectResourceWithID(self.organizer_calendar_resource_id))
             if organizer_resource is not None:
                 yield self._doRefresh(organizer_resource, only_attendees=attendeesToProcess)

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/scheduling/test/test_implicit.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/scheduling/test/test_implicit.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/caldav/datastore/scheduling/test/test_implicit.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -21,10 +21,12 @@
 from twext.web2 import responsecode
 from twext.web2.http import HTTPError
 
+from twisted.internet import reactor
 from twisted.internet.defer import succeed, inlineCallbacks, returnValue
+from twisted.internet.task import deferLater
 from twisted.trial.unittest import TestCase
+
 from twistedcaldav.config import config
-
 from twistedcaldav.ical import Component
 
 from txdav.caldav.datastore.scheduling.implicit import ImplicitScheduler
@@ -1412,3 +1414,91 @@
 
         calendar3 = (yield self._getCalendarData("user03"))
         self.assertTrue("PARTSTAT=ACCEPTED" in calendar3)
+
+
+    @inlineCallbacks
+    def test_doImplicitScheduling_refreshAllAttendeesExceptSome_Batched(self):
+        """
+        Test that doImplicitScheduling delivers scheduling messages to attendees who can then reply.
+        Verify that batched refreshing is working.
+        """
+
+        data1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+ATTENDEE:mailto:user03 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+        data2 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+ATTENDEE:mailto:user03 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+
+        # Need refreshes to occur immediately, not via reactor.callLater
+        self.patch(config.Scheduling.Options, "AttendeeRefreshBatch", 5)
+        self.patch(config.Scheduling.Options, "AttendeeRefreshBatchDelaySeconds", 1)
+
+        yield self._createCalendarObject(data1, "user01", "test.ics")
+
+        list1 = (yield self._listCalendarObjects("user01", "inbox"))
+        self.assertEqual(len(list1), 0)
+
+        calendar1 = (yield self._getCalendarData("user01", "test.ics"))
+        self.assertTrue("SCHEDULE-STATUS=1.2" in calendar1)
+
+        list2 = (yield self._listCalendarObjects("user02", "inbox"))
+        self.assertEqual(len(list2), 1)
+
+        calendar2 = (yield self._getCalendarData("user02"))
+        self.assertTrue("PARTSTAT=ACCEPTED" not in calendar2)
+
+        list3 = (yield self._listCalendarObjects("user03", "inbox"))
+        self.assertEqual(len(list3), 1)
+
+        calendar3 = (yield self._getCalendarData("user03"))
+        self.assertTrue("PARTSTAT=ACCEPTED" not in calendar3)
+
+        yield self._setCalendarData(data2, "user02")
+
+        list1 = (yield self._listCalendarObjects("user01", "inbox"))
+        self.assertEqual(len(list1), 1)
+
+        calendar1 = (yield self._getCalendarData("user01", "test.ics"))
+        self.assertTrue("SCHEDULE-STATUS=2.0" in calendar1)
+        self.assertTrue("PARTSTAT=ACCEPTED" in calendar1)
+
+        list2 = (yield self._listCalendarObjects("user02", "inbox"))
+        self.assertEqual(len(list2), 1)
+
+        calendar2 = (yield self._getCalendarData("user02"))
+        self.assertTrue("PARTSTAT=ACCEPTED" in calendar2)
+
+        @inlineCallbacks
+        def _test_user03_refresh():
+            list3 = (yield self._listCalendarObjects("user03", "inbox"))
+            self.assertEqual(len(list3), 1)
+
+            calendar3 = (yield self._getCalendarData("user03"))
+            self.assertTrue("PARTSTAT=ACCEPTED" in calendar3)
+
+        yield deferLater(reactor, 2.0, _test_user03_refresh)

Modified: CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/common/datastore/sql.py	2013-09-11 16:56:57 UTC (rev 11666)
+++ CalendarServer/branches/users/gaya/sharedgroupfixes/txdav/common/datastore/sql.py	2013-09-11 17:36:20 UTC (rev 11667)
@@ -550,14 +550,6 @@
         ).on(self)
 
 
-    def calendarHomeWithUID(self, uid, create=False):
-        return self.homeWithUID(ECALENDARTYPE, uid, create=create)
-
-
-    def addressbookHomeWithUID(self, uid, create=False):
-        return self.homeWithUID(EADDRESSBOOKTYPE, uid, create=create)
-
-
     def _determineMemo(self, storeType, uid, create=False): #@UnusedVariable
         """
         Determine the memo dictionary to use for homeWithUID.
@@ -591,6 +583,14 @@
         return self._homeClass[storeType].homeWithUID(self, uid, create)
 
 
+    def calendarHomeWithUID(self, uid, create=False):
+        return self.homeWithUID(ECALENDARTYPE, uid, create=create)
+
+
+    def addressbookHomeWithUID(self, uid, create=False):
+        return self.homeWithUID(EADDRESSBOOKTYPE, uid, create=create)
+
+
     @inlineCallbacks
     def homeWithResourceID(self, storeType, rid, create=False):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130911/1e334593/attachment-0001.html>


More information about the calendarserver-changes mailing list