[CalendarServer-changes] [6019] CalendarServer/branches/users/glyph/sql-store

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 9 14:24:58 PDT 2010


Revision: 6019
          http://trac.macosforge.org/projects/calendarserver/changeset/6019
Author:   sagen at apple.com
Date:     2010-08-09 14:24:57 -0700 (Mon, 09 Aug 2010)
Log Message:
-----------
Hooking up master/slaves to postgres

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/sql-store/calendarserver/tap/caldav.py
    CalendarServer/branches/users/glyph/sql-store/calendarserver/tap/util.py
    CalendarServer/branches/users/glyph/sql-store/test
    CalendarServer/branches/users/glyph/sql-store/twistedcaldav/resource.py
    CalendarServer/branches/users/glyph/sql-store/twistedcaldav/stdconfig.py
    CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py
    CalendarServer/branches/users/glyph/sql-store/txdav/datastore/subpostgres.py

Modified: CalendarServer/branches/users/glyph/sql-store/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/calendarserver/tap/caldav.py	2010-08-09 20:49:09 UTC (rev 6018)
+++ CalendarServer/branches/users/glyph/sql-store/calendarserver/tap/caldav.py	2010-08-09 21:24:57 UTC (rev 6019)
@@ -88,6 +88,10 @@
 from calendarserver.tap.util import getRootResource, computeProcessCount
 from calendarserver.tools.util import checkDirectory
 
+from txcaldav.calendarstore.postgres import PostgresStore, v1_schema
+from txdav.datastore.subpostgres import PostgresService
+from twext.python.filepath import CachingFilePath
+
 log = Logger()
 
 
@@ -699,6 +703,22 @@
         loggingService.setName("logging")
         loggingService.setServiceParent(s)
 
+
+        #
+        # Postgres
+        #
+        dbRoot = CachingFilePath(config.DatabaseRoot)
+
+        def subServiceFactory(connectionFactory):
+            return PostgresStore(
+                connectionFactory("FIXME: What label to use here?"),
+                None, # No notifier for master
+                dbRoot.child("attachments")
+            )
+
+        PostgresService(dbRoot, subServiceFactory, v1_schema,
+            "caldav").setServiceParent(s)
+
         monitor = DelayedStartupProcessMonitor()
         monitor.setServiceParent(s)
         s.processMonitor = monitor

Modified: CalendarServer/branches/users/glyph/sql-store/calendarserver/tap/util.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/calendarserver/tap/util.py	2010-08-09 20:49:09 UTC (rev 6018)
+++ CalendarServer/branches/users/glyph/sql-store/calendarserver/tap/util.py	2010-08-09 21:24:57 UTC (rev 6019)
@@ -67,8 +67,11 @@
 from calendarserver.webadmin.resource import WebAdminResource
 from calendarserver.webcal.resource import WebCalendarResource
 
-from txdav.common.datastore.file import CommonDataStore
+from txcaldav.calendarstore.postgres import PostgresStore, v1_schema
+from txdav.datastore.subpostgres import PostgresService
+from twext.python.filepath import CachingFilePath
 
+
 log = Logger()
 
 
@@ -288,8 +291,11 @@
 
 
     # Need a data store
-    _newStore = CommonDataStore(FilePath(config.DocumentRoot),
-        notifierFactory, config.EnableCalDAV, config.EnableCardDAV)
+    _dbRoot = CachingFilePath(config.DatabaseRoot)
+    _postgresService = PostgresService(_dbRoot, None, v1_schema, "caldav")
+    _newStore = PostgresStore(_postgresService.produceConnection,
+        notifierFactory, # config.EnableCalDAV, config.EnableCardDAV)
+        _dbRoot.child("attachments"))
 
     if config.EnableCalDAV:
         log.info("Setting up calendar collection: %r" % (calendarResourceClass,))

Modified: CalendarServer/branches/users/glyph/sql-store/test
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/test	2010-08-09 20:49:09 UTC (rev 6018)
+++ CalendarServer/branches/users/glyph/sql-store/test	2010-08-09 21:24:57 UTC (rev 6019)
@@ -81,4 +81,4 @@
     test_modules="calendarserver twistedcaldav twext txdav txcaldav txcarddav ${m_twisted}";
 fi;
 
-cd "${wd}" && "${python}" "${trial}" --rterrors ${random} ${until_fail} ${no_colour} ${coverage} ${test_modules};
+cd "${wd}" && "${python}" "${trial}" --temp-directory ~/Scratch --rterrors ${random} ${until_fail} ${no_colour} ${coverage} ${test_modules};

Modified: CalendarServer/branches/users/glyph/sql-store/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/twistedcaldav/resource.py	2010-08-09 20:49:09 UTC (rev 6018)
+++ CalendarServer/branches/users/glyph/sql-store/twistedcaldav/resource.py	2010-08-09 21:24:57 UTC (rev 6019)
@@ -2262,7 +2262,7 @@
 
     def createNotificationsCollection(self):
         
-        txn = self._newStoreHome._transaction
+        txn = self._associatedTransaction
         notifications = txn.notificationsWithUID(self._newStoreHome.uid())
 
         from twistedcaldav.storebridge import StoreNotificationCollectionResource

Modified: CalendarServer/branches/users/glyph/sql-store/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/twistedcaldav/stdconfig.py	2010-08-09 20:49:09 UTC (rev 6018)
+++ CalendarServer/branches/users/glyph/sql-store/twistedcaldav/stdconfig.py	2010-08-09 21:24:57 UTC (rev 6019)
@@ -160,6 +160,7 @@
     #
     "ServerRoot"              : "/Library/CalendarServer",
     "DataRoot"                : "Data",
+    "DatabaseRoot"            : "Database",
     "DocumentRoot"            : "Documents",
     "ConfigRoot"              : "/etc/caldavd",
     "LogRoot"                 : "/var/log/caldavd",
@@ -627,6 +628,7 @@
                   ("ServerRoot", "ConfigRoot"),
                   ("ServerRoot", "LogRoot"),
                   ("ServerRoot", "RunRoot"),
+                  ("DataRoot", "DatabaseRoot"),
                   ("ConfigRoot", "SudoersFile"),
                   ("LogRoot", "AccessLogFile"),
                   ("LogRoot", "ErrorLogFile"),

Modified: CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py	2010-08-09 20:49:09 UTC (rev 6018)
+++ CalendarServer/branches/users/glyph/sql-store/txcaldav/calendarstore/postgres.py	2010-08-09 21:24:57 UTC (rev 6019)
@@ -253,7 +253,8 @@
             "where RESOURCE_ID = %s", [calendarText, self._resourceID]
         )
         self._calendarText = calendarText
-        self._calendar._home._txn.postCommit(self._calendar._notifier.notify)
+        if self._calendar._notifier:
+            self._calendar._home._txn.postCommit(self._calendar._notifier.notify)
 
 
     def _attachmentPath(self, name):
@@ -722,7 +723,8 @@
             [self._resourceID, name, componentText, component.resourceUID(),
             component.resourceType(), _ATTACHMENTS_MODE_WRITE]
         )
-        self._home._txn.postCommit(self._notifier.notify)
+        if self._notifier:
+            self._home._txn.postCommit(self._notifier.notify)
 
 
     def removeCalendarObjectWithName(self, name):
@@ -734,7 +736,8 @@
         if self._txn._cursor.rowcount == 0:
             raise NoSuchObjectResourceError()
         self._objects.pop(name, None)
-        self._txn.postCommit(self._notifier.notify)
+        if self._notifier:
+            self._txn.postCommit(self._notifier.notify)
 
 
     def removeCalendarObjectWithUID(self, uid):
@@ -752,7 +755,8 @@
             [uid, self._resourceID]
         )
         self._objects.pop(name, None)
-        self._home._txn.postCommit(self._notifier.notify)
+        if self._notifier:
+            self._home._txn.postCommit(self._notifier.notify)
 
 
     def syncToken(self):
@@ -883,8 +887,11 @@
         if not data:
             return None
         resourceID = data[0][0]
-        childID = "%s/%s" % (self.uid(), name)
-        notifier = self._notifier.clone(label="collection", id=childID)
+        if self._notifier:
+            childID = "%s/%s" % (self.uid(), name)
+            notifier = self._notifier.clone(label="collection", id=childID)
+        else:
+            notifier = None
         return PostgresCalendar(self, name, resourceID, notifier)
 
 
@@ -928,7 +935,8 @@
         calendarType = ResourceType.calendar #@UndefinedVariable
         self.calendarWithName(name).properties()[
             PropertyName.fromElement(ResourceType)] = calendarType
-        self._txn.postCommit(self._notifier.notify)
+        if self._notifier:
+            self._txn.postCommit(self._notifier.notify)
 
 
     def removeCalendarWithName(self, name):
@@ -942,7 +950,8 @@
             raise NoSuchHomeChildError()
         # FIXME: the schema should probably cascade the calendar delete when
         # the last bind is deleted.
-        self._txn.postCommit(self._notifier.notify)
+        if self._notifier:
+            self._txn.postCommit(self._notifier.notify)
 
 
     def properties(self):
@@ -1037,7 +1046,12 @@
             home.createCalendarWithName("calendar")
             return home
         resid = data[0][0]
-        notifier = self._notifierFactory.newNotifier(id=uid)
+
+        if self._notifierFactory:
+            notifier = self._notifierFactory.newNotifier(id=uid)
+        else:
+            notifier = None
+
         return PostgresCalendarHome(self, uid, resid, notifier)
 
 

Modified: CalendarServer/branches/users/glyph/sql-store/txdav/datastore/subpostgres.py
===================================================================
--- CalendarServer/branches/users/glyph/sql-store/txdav/datastore/subpostgres.py	2010-08-09 20:49:09 UTC (rev 6018)
+++ CalendarServer/branches/users/glyph/sql-store/txdav/datastore/subpostgres.py	2010-08-09 21:24:57 UTC (rev 6019)
@@ -168,6 +168,7 @@
         MultiService.__init__(self)
         self.subServiceFactory = subServiceFactory
         self.dataStoreDirectory = dataStoreDirectory
+        self.socketDir = self.dataStoreDirectory.child("socket")
         self.databaseName = databaseName
         self.schema = schema
         self.monitor = None
@@ -286,7 +287,6 @@
     def startService(self):
         MultiService.startService(self)
         clusterDir = self.dataStoreDirectory.child("cluster")
-        self.socketDir = self.dataStoreDirectory.child("socket")
         workingDir = self.dataStoreDirectory.child("working")
         env = self.env = os.environ.copy()
         env.update(PGDATA=clusterDir.path,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100809/80714f05/attachment-0001.html>


More information about the calendarserver-changes mailing list