[CalendarServer-changes] [14506] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 4 14:48:03 PST 2015


Revision: 14506
          http://trac.calendarserver.org//changeset/14506
Author:   wsanchez at apple.com
Date:     2015-03-04 14:48:03 -0800 (Wed, 04 Mar 2015)
Log Message:
-----------
Get rid of importFileName argument to PostgresService's init.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tap/util.py
    CalendarServer/trunk/conf/caldavd-apple.plist
    CalendarServer/trunk/twistedcaldav/stdconfig.py
    CalendarServer/trunk/txdav/base/datastore/subpostgres.py
    CalendarServer/trunk/txdav/base/datastore/test/test_subpostgres.py

Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py	2015-03-04 22:44:38 UTC (rev 14505)
+++ CalendarServer/trunk/calendarserver/tap/util.py	2015-03-04 22:48:03 UTC (rev 14506)
@@ -150,7 +150,6 @@
         options=config.Postgres.Options,
         uid=uid, gid=gid,
         spawnedDBUser=config.SpawnedDBUser,
-        importFileName=config.DBImportFile,
         pgCtl=config.Postgres.Ctl,
         initDB=config.Postgres.Init,
     )

Modified: CalendarServer/trunk/conf/caldavd-apple.plist
===================================================================
--- CalendarServer/trunk/conf/caldavd-apple.plist	2015-03-04 22:44:38 UTC (rev 14505)
+++ CalendarServer/trunk/conf/caldavd-apple.plist	2015-03-04 22:48:03 UTC (rev 14506)
@@ -99,8 +99,6 @@
     <string></string>
     <key>DSN</key>
     <string></string>
-    <key>DBImportFile</key>
-    <string>/Library/Server/Calendar and Contacts/DataDump.sql</string>
     <key>Postgres</key>
     <dict>
         <key>Ctl</key>

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2015-03-04 22:44:38 UTC (rev 14505)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2015-03-04 22:48:03 UTC (rev 14506)
@@ -202,8 +202,6 @@
 
     "SpawnedDBUser": "caldav", # The username to use when DBType is empty
 
-    "DBImportFile": "", # File path to SQL file to import at startup (includes schema)
-
     "DSN": "", # Data Source Name.  Used to connect to an external
                # database if DBType is non-empty.  Format varies
                # depending on database type.

Modified: CalendarServer/trunk/txdav/base/datastore/subpostgres.py
===================================================================
--- CalendarServer/trunk/txdav/base/datastore/subpostgres.py	2015-03-04 22:44:38 UTC (rev 14505)
+++ CalendarServer/trunk/txdav/base/datastore/subpostgres.py	2015-03-04 22:48:03 UTC (rev 14506)
@@ -186,7 +186,6 @@
         testMode=False,
         uid=None, gid=None,
         spawnedDBUser="caldav",
-        importFileName=None,
         pgCtl="pg_ctl",
         initDB="initdb",
         reactor=None,
@@ -203,9 +202,6 @@
 
         @param spawnedDBUser: the postgres role
         @type spawnedDBUser: C{str}
-        @param importFileName: path to SQL file containing previous data to
-            import
-        @type importFileName: C{str}
         """
 
         # FIXME: By default there is very little (4MB) shared memory available,
@@ -269,7 +265,6 @@
         self.uid = uid
         self.gid = gid
         self.spawnedDBUser = spawnedDBUser
-        self.importFileName = importFileName
         self.schema = schema
         self.monitor = None
         self.openConnections = []
@@ -422,10 +417,6 @@
             # otherwise execute schema
             executeSQL = True
             sqlToExecute = self.schema
-            if self.importFileName:
-                importFilePath = CachingFilePath(self.importFileName)
-                if importFilePath.exists():
-                    sqlToExecute = importFilePath.getContent()
 
         createDatabaseCursor.close()
         createDatabaseConn.close()

Modified: CalendarServer/trunk/txdav/base/datastore/test/test_subpostgres.py
===================================================================
--- CalendarServer/trunk/txdav/base/datastore/test/test_subpostgres.py	2015-03-04 22:44:38 UTC (rev 14505)
+++ CalendarServer/trunk/txdav/base/datastore/test/test_subpostgres.py	2015-03-04 22:48:03 UTC (rev 14506)
@@ -139,61 +139,3 @@
         cursor.execute("select * from test_dummy_table")
         values = cursor.fetchall()
         self.assertEquals(map(list, values), [["dummy"]])
-
-
-    @inlineCallbacks
-    def test_startService_withDumpFile(self):
-        """
-        Assuming a properly configured environment ($PATH points at an 'initdb'
-        and 'postgres', $PYTHONPATH includes pgdb), starting a
-        L{PostgresService} will start the service passed to it, after importing
-        an existing dump file.
-        """
-
-        test = self
-
-        class SimpleService1(Service):
-
-            instances = []
-            ready = Deferred()
-
-            def __init__(self, connectionFactory, storageService):
-                self.connection = connectionFactory()
-                test.addCleanup(self.connection.close)
-                self.instances.append(self)
-
-
-            def startService(self):
-                cursor = self.connection.cursor()
-                try:
-                    cursor.execute(
-                        "insert into import_test_table values ('value2')"
-                    )
-                except:
-                    self.ready.errback()
-                else:
-                    self.ready.callback(None)
-                finally:
-                    cursor.close()
-
-        # The SQL in importFile.sql will get executed, including the insertion
-        # of "value1"
-        importFileName = (
-            CachingFilePath(__file__).parent().child("importFile.sql").path
-        )
-        svc = PostgresService(
-            CachingFilePath("postgres_3.pgdb"),
-            SimpleService1,
-            "",
-            databaseName="dummy_db",
-            testMode=True,
-            importFileName=importFileName
-        )
-        svc.startService()
-        self.addCleanup(svc.stopService)
-        yield SimpleService1.ready
-        connection = SimpleService1.instances[0].connection
-        cursor = connection.cursor()
-        cursor.execute("select * from import_test_table")
-        values = cursor.fetchall()
-        self.assertEquals(map(list, values), [["value1"], ["value2"]])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150304/8f962826/attachment.html>


More information about the calendarserver-changes mailing list