[CalendarServer-changes] [1706] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jul 20 17:26:49 PDT 2007
Revision: 1706
http://trac.macosforge.org/projects/calendarserver/changeset/1706
Author: cdaboo at apple.com
Date: 2007-07-20 17:26:48 -0700 (Fri, 20 Jul 2007)
Log Message:
-----------
Merge of branches/users/cdaboo/dbprefix-1689 to trunk.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/admin/purge.py
CalendarServer/trunk/twistedcaldav/admin/util.py
CalendarServer/trunk/twistedcaldav/directory/calendaruserproxy.py
CalendarServer/trunk/twistedcaldav/directory/digest.py
CalendarServer/trunk/twistedcaldav/directory/sqldb.py
CalendarServer/trunk/twistedcaldav/index.py
CalendarServer/trunk/twistedcaldav/sql.py
CalendarServer/trunk/twistedcaldav/static.py
CalendarServer/trunk/twistedcaldav/test/test_sql.py
Modified: CalendarServer/trunk/twistedcaldav/admin/purge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/admin/purge.py 2007-07-21 00:05:40 UTC (rev 1705)
+++ CalendarServer/trunk/twistedcaldav/admin/purge.py 2007-07-21 00:26:48 UTC (rev 1706)
@@ -18,6 +18,8 @@
import datetime
+from twistedcaldav.sql import db_prefix
+
def purgeEvents(collection, purgeDate):
"""
Recursively purge all events older than purgeDate.
@@ -36,7 +38,7 @@
directories = []
for child in collection.children():
- if child.basename() == '.db.sqlite':
+ if child.basename().startswith(db_prefix):
continue
if child.isdir():
Modified: CalendarServer/trunk/twistedcaldav/admin/util.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/admin/util.py 2007-07-21 00:05:40 UTC (rev 1705)
+++ CalendarServer/trunk/twistedcaldav/admin/util.py 2007-07-21 00:26:48 UTC (rev 1706)
@@ -23,6 +23,7 @@
from twisted.web import microdom
from twistedcaldav import ical
+from twistedcaldav.sql import db_prefix
def prepareByteValue(config, value):
if config.get('human', None):
@@ -64,7 +65,7 @@
if typeRoot.exists():
for child in typeRoot.listdir():
- if child not in ['.db.sqlite']:
+ if not child.startswith(db_prefix):
p = typeRoot.child(child)
if disabled:
Modified: CalendarServer/trunk/twistedcaldav/directory/calendaruserproxy.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/calendaruserproxy.py 2007-07-21 00:05:40 UTC (rev 1705)
+++ CalendarServer/trunk/twistedcaldav/directory/calendaruserproxy.py 2007-07-21 00:26:48 UTC (rev 1706)
@@ -37,6 +37,7 @@
from twistedcaldav.extensions import DAVFile, DAVPrincipalResource
from twistedcaldav.extensions import ReadOnlyWritePropertiesResourceMixIn
from twistedcaldav.sql import AbstractSQLDatabase
+from twistedcaldav.sql import db_prefix
from twistedcaldav.static import AutoProvisioningFileMixIn
from twistedcaldav.directory.util import uuidFromName
@@ -296,7 +297,7 @@
"""
dbType = "CALENDARUSERPROXY"
- dbFilename = ".db.calendaruserproxy"
+ dbFilename = db_prefix + "calendaruserproxy"
dbFormatVersion = "3"
def __init__(self, path):
Modified: CalendarServer/trunk/twistedcaldav/directory/digest.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/digest.py 2007-07-21 00:05:40 UTC (rev 1705)
+++ CalendarServer/trunk/twistedcaldav/directory/digest.py 2007-07-21 00:26:48 UTC (rev 1706)
@@ -17,6 +17,7 @@
##
from twistedcaldav.sql import AbstractSQLDatabase
+from twistedcaldav.sql import db_prefix
from twisted.cred import error
from twisted.python import log
@@ -154,7 +155,7 @@
"""
dbType = "DIGESTCREDENTIALSCACHE"
- dbFilename = ".db.digestcredentialscache"
+ dbFilename = db_prefix + "digestcredentialscache"
dbFormatVersion = "2"
exceptionLimit = 10
Modified: CalendarServer/trunk/twistedcaldav/directory/sqldb.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/sqldb.py 2007-07-21 00:05:40 UTC (rev 1705)
+++ CalendarServer/trunk/twistedcaldav/directory/sqldb.py 2007-07-21 00:26:48 UTC (rev 1706)
@@ -47,6 +47,7 @@
from twistedcaldav.directory.directory import DirectoryService, DirectoryRecord
from twistedcaldav.directory.xmlaccountsparser import XMLAccountsParser
from twistedcaldav.sql import AbstractSQLDatabase
+from twistedcaldav.sql import db_prefix
import os
@@ -56,7 +57,7 @@
and record dumping. This can be used as a standalong DB management tool.
"""
dbType = "DIRECTORYSERVICE"
- dbFilename = ".db.accounts"
+ dbFilename = db_prefix + "accounts"
dbFormatVersion = "3"
def __init__(self, path):
Modified: CalendarServer/trunk/twistedcaldav/index.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/index.py 2007-07-21 00:05:40 UTC (rev 1705)
+++ CalendarServer/trunk/twistedcaldav/index.py 2007-07-21 00:26:48 UTC (rev 1706)
@@ -42,11 +42,12 @@
from twistedcaldav.ical import Component
from twistedcaldav.query import calendarquery
from twistedcaldav.sql import AbstractSQLDatabase
+from twistedcaldav.sql import db_prefix
from twistedcaldav import caldavxml
from vobject.icalendar import utc
-db_basename = ".db.sqlite"
+db_basename = db_prefix + "sqlite"
schema_version = "6"
collection_types = {"Calendar": "Regular Calendar Collection", "iTIP": "iTIP Calendar Collection"}
@@ -565,7 +566,7 @@
#
fp = self.resource.fp
for name in fp.listdir():
- if name == db_basename:
+ if name.startswith(db_prefix):
continue
try:
@@ -676,7 +677,7 @@
#
fp = self.resource.fp
for name in fp.listdir():
- if name == db_basename:
+ if name.startswith(db_prefix):
continue
try:
Modified: CalendarServer/trunk/twistedcaldav/sql.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sql.py 2007-07-21 00:05:40 UTC (rev 1705)
+++ CalendarServer/trunk/twistedcaldav/sql.py 2007-07-21 00:26:48 UTC (rev 1706)
@@ -33,6 +33,8 @@
from twisted.python import log
+db_prefix = ".db."
+
class AbstractSQLDatabase(object):
"""
A generic SQL database.
Modified: CalendarServer/trunk/twistedcaldav/static.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/static.py 2007-07-21 00:05:40 UTC (rev 1705)
+++ CalendarServer/trunk/twistedcaldav/static.py 2007-07-21 00:26:48 UTC (rev 1706)
@@ -60,7 +60,7 @@
from twistedcaldav.extensions import DAVFile
from twistedcaldav.ical import Component as iComponent
from twistedcaldav.ical import Property as iProperty
-from twistedcaldav.index import Index, IndexSchedule, db_basename
+from twistedcaldav.index import Index, IndexSchedule
from twistedcaldav.notifications import NotificationsCollectionResource, NotificationResource
from twistedcaldav.resource import CalDAVResource, isCalendarCollectionResource, isPseudoCalendarCollectionResource
from twistedcaldav.schedule import ScheduleInboxResource, ScheduleOutboxResource
@@ -69,6 +69,7 @@
from twistedcaldav.directory.calendar import DirectoryCalendarHomeTypeProvisioningResource
from twistedcaldav.directory.calendar import DirectoryCalendarHomeResource
from twistedcaldav.directory.resource import AutoProvisioningResourceMixIn
+from twistedcaldav.sql import db_prefix
class CalDAVFile (CalDAVResource, DAVFile):
"""
@@ -278,7 +279,7 @@
def listChildren(self):
return [
child for child in super(CalDAVFile, self).listChildren()
- if child != db_basename
+ if not child.startswith(db_prefix)
]
def updateCTag(self):
@@ -310,7 +311,7 @@
for f in top.listdir():
# Ignore the database
- if f == db_basename:
+ if f.startswith(db_prefix):
continue
child = top.child(f)
Modified: CalendarServer/trunk/twistedcaldav/test/test_sql.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_sql.py 2007-07-21 00:05:40 UTC (rev 1705)
+++ CalendarServer/trunk/twistedcaldav/test/test_sql.py 2007-07-21 00:26:48 UTC (rev 1706)
@@ -19,6 +19,8 @@
from twistedcaldav.sql import AbstractSQLDatabase
import twistedcaldav.test.util
+from twistedcaldav.sql import db_prefix
+import os
class SQL (twistedcaldav.test.util.TestCase):
"""
@@ -137,3 +139,16 @@
db._db_close()
self.assertFalse(hasattr(db, "_db_connection"))
db._db_close()
+
+ def test_ignore_db_files(self):
+ """
+ Make sure database files are not listed as children.
+ """
+ colpath = self.site.resource.fp.path
+ fd = open(os.path.join(colpath, db_prefix + "sqlite"), "w")
+ fd.close()
+ fd = open(os.path.join(colpath, "test"), "w")
+ fd.close()
+ children = self.site.resource.listChildren()
+ self.assertTrue("test" in children)
+ self.assertFalse(db_prefix + "sqlite" in children)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070720/35a0af74/attachment.html
More information about the calendarserver-changes
mailing list