[CalendarServer-changes] [6518] CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 1 14:20:23 PDT 2010


Revision: 6518
          http://trac.macosforge.org/projects/calendarserver/changeset/6518
Author:   glyph at apple.com
Date:     2010-11-01 14:20:18 -0700 (Mon, 01 Nov 2010)
Log Message:
-----------
factor out config->postgres service transformation

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/caldav.py
    CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/util.py

Modified: CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/caldav.py	2010-11-01 21:19:55 UTC (rev 6517)
+++ CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/caldav.py	2010-11-01 21:20:18 UTC (rev 6518)
@@ -59,8 +59,6 @@
 from twext.web2.channel.http import LimitingHTTPFactory, SSLRedirectRequest
 from twext.web2.metafd import ConnectionLimiter, ReportingHTTPService
 
-from txdav.common.datastore.sql import v1_schema
-from txdav.base.datastore.subpostgres import PostgresService
 from txdav.common.datastore.util import UpgradeToDatabaseService
 
 from twistedcaldav.config import ConfigurationError
@@ -72,6 +70,7 @@
 from twistedcaldav.stdconfig import DEFAULT_CONFIG, DEFAULT_CONFIG_FILE
 from twistedcaldav.upgrade import upgradeData
 
+from calendarserver.tap.util import pgServiceFromConfig
 try:
     from twistedcaldav.authkerb import NegotiateCredentialFactory
     NegotiateCredentialFactory  # pacify pyflakes
@@ -751,17 +750,7 @@
             else:
                 postgresUID = None
                 postgresGID = None
-            pgserv = PostgresService(
-                dbRoot, subServiceFactory, v1_schema,
-                databaseName=config.Postgres.DatabaseName,
-                logFile=config.Postgres.LogFile,
-                socketDir=config.RunRoot,
-                listenAddresses=config.Postgres.ListenAddresses,
-                sharedBuffers=config.Postgres.SharedBuffers,
-                maxConnections=config.Postgres.MaxConnections,
-                options=config.Postgres.Options,
-                uid=postgresUID, gid=postgresGID
-            )
+            pgserv = pgServiceFromConfig(config, subServiceFactory, uid, gid)
             return pgserv
         else:
             return mainService

Modified: CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/util.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/util.py	2010-11-01 21:19:55 UTC (rev 6517)
+++ CalendarServer/branches/users/glyph/sharedpool/calendarserver/tap/util.py	2010-11-01 21:20:18 UTC (rev 6518)
@@ -78,33 +78,39 @@
 log = Logger()
 
 
+def pgServiceFromConfig(config, subServiceFactory, uid=None, gid=None):
+    """
+    Construct a L{PostgresService} from a given configuration and subservice.
+    """
+    dbRoot = CachingFilePath(config.DatabaseRoot)
+    # Construct a PostgresService exactly as the parent would, so that we
+    # can establish connection information.
+    return PostgresService(
+        dbRoot, subServiceFactory, v1_schema,
+        databaseName=config.Postgres.DatabaseName,
+        logFile=config.Postgres.LogFile,
+        socketDir=config.RunRoot,
+        listenAddresses=config.Postgres.ListenAddresses,
+        sharedBuffers=config.Postgres.SharedBuffers,
+        maxConnections=config.Postgres.MaxConnections,
+        options=config.Postgres.Options,
+        uid=uid, gid=gid
+    )
 
+
+
 def storeFromConfig(config, serviceParent, notifierFactory=None):
     """
     Produce an L{IDataStore} from the given configuration and notifier factory.
     """
     if config.UseDatabase:
-        dbRoot = CachingFilePath(config.DatabaseRoot)
-
-        # Construct a PostgresService exactly as the parent would, so that we
-        # can establish connection information.
-        postgresService = PostgresService(
-            dbRoot, None, v1_schema,
-            databaseName=config.Postgres.DatabaseName,
-            logFile=config.Postgres.LogFile,
-            socketDir=config.RunRoot,
-            listenAddresses=config.Postgres.ListenAddresses,
-            sharedBuffers=config.Postgres.SharedBuffers,
-            maxConnections=config.Postgres.MaxConnections,
-            options=config.Postgres.Options,
-        )
-
+        postgresService = pgServiceFromConfig(config, None)
         cp = ConnectionPool(postgresService.produceConnection)
         cp.setServiceParent(serviceParent)
 
         dataStore = CommonSQLDataStore(
-            cp.connection,
-            notifierFactory, dbRoot.child("attachments"),
+            cp.connection, notifierFactory,
+            postgresService.dataStoreDirectory.child("attachments"),
             config.EnableCalDAV, config.EnableCardDAV
         )
         dataStore.setServiceParent(serviceParent)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101101/1c29500b/attachment-0001.html>


More information about the calendarserver-changes mailing list