[CalendarServer-changes] [11182] CalendarServer/branches/users/gaya/sharedgroups-3
source_changes at macosforge.org
source_changes at macosforge.org
Tue May 14 17:32:59 PDT 2013
Revision: 11182
http://trac.calendarserver.org//changeset/11182
Author: gaya at apple.com
Date: 2013-05-14 17:32:59 -0700 (Tue, 14 May 2013)
Log Message:
-----------
update to 11173
Modified Paths:
--------------
CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/test/test_caldav.py
CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/util.py
CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/managetimezones.py
CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/deprovision/caldavd.plist
CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/gateway/caldavd.plist
CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/principals/caldavd.plist
CalendarServer/branches/users/gaya/sharedgroups-3/conf/caldavd-test.plist
CalendarServer/branches/users/gaya/sharedgroups-3/setup.py
CalendarServer/branches/users/gaya/sharedgroups-3/support/Apple.make
CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/scheduling_store/caldav/test/test_resource.py
CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/stdconfig.py
CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/test_extensions.py
CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/test_timezones.py
CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/util.py
CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/timezones.py
CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/timezonestdservice.py
CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/zoneinfo/version.txt
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/base/datastore/subpostgres.py
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql.py
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_19_to_20.sql
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_19_to_20.sql
Added Paths:
-----------
CalendarServer/branches/users/gaya/sharedgroups-3/doc/calendarserver_manage_timezones.8
Property Changed:
----------------
CalendarServer/branches/users/gaya/sharedgroups-3/
CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql.py
Property changes on: CalendarServer/branches/users/gaya/sharedgroups-3
___________________________________________________________________
Modified: svn:mergeinfo
- /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/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/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/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/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/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:11090-11095,11097-11111,11115-11165
+ /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/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/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/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/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/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:11090-11095,11097-11111,11115-11174
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/test/test_caldav.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/test/test_caldav.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/test/test_caldav.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -349,6 +349,7 @@
self.config.Memcached.Pools.Default.ClientEnabled = False
self.config.Memcached.Pools.Default.ServerEnabled = False
self.config.DirectoryAddressBook.Enabled = False
+ self.config.UsePackageTimezones = True
if self.configOptions:
self.config.update(self.configOptions)
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/util.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/util.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tap/util.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -588,6 +588,10 @@
resource = FileResource(info["path"])
root.putChild(name, resource)
+ # Need timezone cache before setting up any timezone service
+ log.info("Setting up Timezone Cache")
+ TimezoneCache.create()
+
# Timezone service is optional
if config.EnableTimezoneService:
log.info("Setting up time zone service resource: %r"
@@ -678,9 +682,6 @@
#
# Configure ancillary data
#
- log.info("Setting up Timezone Cache")
- TimezoneCache.create()
-
log.info("Configuring authentication wrapper")
overrides = {}
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/managetimezones.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/managetimezones.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/managetimezones.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -25,6 +25,9 @@
from twisted.internet.defer import inlineCallbacks
from twisted.python.filepath import FilePath
+from calendarserver.tools.util import loadConfig
+from twistedcaldav.config import ConfigurationError
+from twistedcaldav.timezones import TimezoneCache
from twistedcaldav.timezonestdservice import PrimaryTimezoneDatabase, \
SecondaryTimezoneDatabase
@@ -36,6 +39,7 @@
import tarfile
import tempfile
import urllib
+from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
def _doPrimaryActions(action, tzpath, xmlfile, changed, tzvers):
@@ -68,10 +72,9 @@
print("Downloading latest data from IANA")
if tzvers:
- path = "http://www.iana.org/time-zones/repository/releases/tzdata%s.tar.gz" % (tzvers,)
+ path = "https://www.iana.org/time-zones/repository/releases/tzdata%s.tar.gz" % (tzvers,)
else:
- path = "http://www.iana.org/time-zones/repository/tzdata-latest.tar.gz"
- tzvers = "Latest (%s)" % (PyCalendarDateTime.getToday().getText(),)
+ path = "https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz"
data = urllib.urlretrieve(path)
print("Extract data at: %s" % (data[0]))
rootdir = tempfile.mkdtemp()
@@ -79,7 +82,21 @@
os.mkdir(zonedir)
with tarfile.open(data[0], "r:gz") as t:
t.extractall(zonedir)
- print("Converting data at: %s" % (zonedir,))
+
+ # Get the version from the Makefile
+ try:
+ makefile = open(os.path.join(zonedir, "Makefile")).read()
+ lines = makefile.splitlines()
+ for line in lines:
+ if line.startswith("VERSION="):
+ tzvers = line[8:].strip()
+ break
+ except IOError:
+ pass
+
+ if not tzvers:
+ tzvers = PyCalendarDateTime.getToday().getText()
+ print("Converting data (version: %s) at: %s" % (tzvers, zonedir,))
startYear = 1800
endYear = PyCalendarDateTime.getToday().getYear() + 10
PyCalendar.sProdID = "-//calendarserver.org//Zonal//EN"
@@ -106,7 +123,7 @@
versfile = os.path.join(os.path.dirname(xmlfile), "version.txt")
print("Updating version file at: %s" % (versfile,))
with open(versfile, "w") as f:
- f.write("Olson data source: %s\n" % (tzvers,))
+ f.write(TimezoneCache.IANA_VERSION_PREFIX + tzvers)
@@ -212,26 +229,29 @@
print("""Usage: managetimezones [options]
Options:
-h Print this help and exit
- -f XML file path
+ -f config file path [REQUIRED]
+ -x XML file path
-z zoneinfo file path
+ --tzvers year/release letter of IANA data to refresh
+ default: use the latest release
+ --url URL or domain of secondary service
# Primary service
--refresh refresh data from IANA
+ --refreshpkg refresh package data from IANA
--create create new XML file
--update update XML file
--list list timezones in XML file
--changed changed since timestamp
- --tzvers year/release letter of IANA data to refresh
- default: use the latest release
# Secondary service
- --url URL or domain of service
--cache Cache data from service
Description:
- This utility will create, update or list an XML timezone database
- summary file, or refresh iCalendar timezone from IANA (Olson).
+ This utility will create, update, or list an XML timezone database
+ summary file, or refresh iCalendar timezone from IANA (Olson). It can
+ also be used to update the server's own zoneinfo database from IANA.
""")
@@ -243,6 +263,7 @@
def main():
+ configFileName = DEFAULT_CONFIG_FILE
primary = False
secondary = False
action = None
@@ -251,13 +272,15 @@
changed = None
url = None
tzvers = None
+ updatepkg = False
# Get options
options, _ignore_args = getopt.getopt(
sys.argv[1:],
- "hf:z:",
+ "f:hx:z:",
[
"refresh",
+ "refreshpkg",
"create",
"update",
"list",
@@ -272,12 +295,18 @@
if option == "-h":
usage()
elif option == "-f":
+ configFileName = value
+ elif option == "-x":
xmlfile = value
elif option == "-z":
tzpath = value
elif option == "--refresh":
action = "refresh"
primary = True
+ elif option == "--refreshpkg":
+ action = "refresh"
+ primary = True
+ updatepkg = True
elif option == "--create":
action = "create"
primary = True
@@ -302,16 +331,29 @@
else:
usage("Unrecognized option: %s" % (option,))
+ if configFileName is None:
+ usage("A configuration file must be specified")
+ try:
+ loadConfig(configFileName)
+ except ConfigurationError, e:
+ sys.stdout.write("%s\n" % (e,))
+ sys.exit(1)
+
if action is None:
action = "list"
primary = True
if tzpath is None:
- try:
- import pkg_resources
- except ImportError:
- tzpath = os.path.join(os.path.dirname(__file__), "zoneinfo")
+ if updatepkg:
+ try:
+ import pkg_resources
+ except ImportError:
+ tzpath = os.path.join(os.path.dirname(__file__), "zoneinfo")
+ else:
+ tzpath = pkg_resources.resource_filename("twistedcaldav", "zoneinfo") #@UndefinedVariable
else:
- tzpath = pkg_resources.resource_filename("twistedcaldav", "zoneinfo") #@UndefinedVariable
+ # Setup the correct zoneinfo path based on the config
+ tzpath = TimezoneCache.getDBPath()
+ TimezoneCache.validatePath()
if xmlfile is None:
xmlfile = os.path.join(tzpath, "timezones.xml")
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/deprovision/caldavd.plist
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/deprovision/caldavd.plist 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/deprovision/caldavd.plist 2013-05-15 00:32:59 UTC (rev 11182)
@@ -688,7 +688,10 @@
<key>EnableTimezoneService</key>
<true/>
+ <key>UsePackageTimezones</key>
+ <true/>
+
<!--
Miscellaneous items
-->
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/gateway/caldavd.plist
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/gateway/caldavd.plist 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/gateway/caldavd.plist 2013-05-15 00:32:59 UTC (rev 11182)
@@ -666,6 +666,8 @@
<key>EnableTimezoneService</key>
<true/>
+ <key>UsePackageTimezones</key>
+ <true/>
<!--
Miscellaneous items
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/principals/caldavd.plist
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/principals/caldavd.plist 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/calendarserver/tools/test/principals/caldavd.plist 2013-05-15 00:32:59 UTC (rev 11182)
@@ -692,7 +692,10 @@
<key>EnableTimezoneService</key>
<true/>
+ <key>UsePackageTimezones</key>
+ <true/>
+
<!--
Miscellaneous items
-->
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/conf/caldavd-test.plist
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/conf/caldavd-test.plist 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/conf/caldavd-test.plist 2013-05-15 00:32:59 UTC (rev 11182)
@@ -850,6 +850,9 @@
</dict>
</dict>
+ <key>UsePackageTimezones</key>
+ <true/>
+
<!-- Batch Upload via POST -->
<key>EnableBatchUpload</key>
<true/>
Copied: CalendarServer/branches/users/gaya/sharedgroups-3/doc/calendarserver_manage_timezones.8 (from rev 11174, CalendarServer/trunk/doc/calendarserver_manage_timezones.8)
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/doc/calendarserver_manage_timezones.8 (rev 0)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/doc/calendarserver_manage_timezones.8 2013-05-15 00:32:59 UTC (rev 11182)
@@ -0,0 +1,107 @@
+.\"
+.\" Copyright (c) 2006-2013 Apple Inc. All rights reserved.
+.\"
+.\" Licensed under the Apache License, Version 2.0 (the "License");
+.\" you may not use this file except in compliance with the License.
+.\" You may obtain a copy of the License at
+.\"
+.\" http://www.apache.org/licenses/LICENSE-2.0
+.\"
+.\" Unless required by applicable law or agreed to in writing, software
+.\" distributed under the License is distributed on an "AS IS" BASIS,
+.\" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+.\" See the License for the specific language governing permissions and
+.\" limitations under the License.
+.\"
+.\" The following requests are required for all man pages.
+.Dd May 11, 2013
+.Dt CALENDARSERVER_MANAGE_TIMEZONES 8
+.Os
+.Sh NAME
+.Nm calendarserver_manage_timezones
+.Nd Calendar Server timezone database management utility
+.Sh SYNOPSIS
+.Nm
+.Op Fl f Ar file
+.Op Fl h
+.Op Fl x Ar file
+.Op Fl z Ar directory
+.Op Fl -tzvers Ar tzdb-version
+.Op Fl -url Ar url
+.Op Fl -refresh
+.Op Fl -refreshpkg
+.Op Fl -create
+.Op Fl -update
+.Op Fl -list
+.Op Fl -changed Ar date
+.Op Fl -cache
+.Sh DESCRIPTION
+.Nm
+This utility will create, update, or list an XML timezone database
+summary XML file, or refresh timezone data from IANA, or refresh
+timezone data from another timezone server.
+.Pp
+It can also be used to update the server's own zoneinfo database
+from IANA.
+.Pp
+It should be run as a user with the same privileges as the Calendar
+Server itself, as it needs to read and write data that belongs to the
+server. If using the --refreshpkg option it will need to write to
+the actual python package data so will need to be run as root.
+.Pp
+Actions to perform are specified via the options below. Only one
+action is allowed.
+.Sh OPTIONS
+.Bl -tag -width flag
+.It Fl h
+Displays usage information
+.It Fl f Ar FILE
+Use the Calendar Server configuration specified in the given file.
+Defaults to /etc/caldavd/caldavd.plist.
+.It Fl x Ar FILE
+Update the timezone database XML file at the specified location.
+Defaults to timezones.xml in the zoneinfo directory.
+.It Fl z Ar DIRECTORY
+Path to a zoneinfo directory where timezone data is stored.
+Defaults to the configuration file's Data/zoneinfo directory.
+.It Fl -tzvers Ar version
+Name of IANA timezone data version to use (e.g., '2013a').
+.It Fl -url
+If the server is configured as a secondary timezone zone, use this URL
+as the URL of the secondary server to pull timezone data from.
+.El
+.Sh ACTIONS
+.Bl -tag -width flag
+.It Fl -refresh
+Update the zoneinfo data from the IANA registry.
+.It Fl -refreshpkg
+Update the server's zoneinfo package data from the IANA registry.
+This updates twistedcaldav.zoneinfo and should only be used by
+server developers wishing to update the server repository.
+.It Fl -create
+Create a new timezone database XML file based on the timezone data
+currently in the zoneinfo directory.
+.It Fl -update
+Update the timezone database XML file based on the timezone data
+currently in the zoneinfo directory.
+.It Fl -list
+List the timezones specified in the timezone database XML file.
+.It Fl -changed Ar date
+List the timezones in the timezone database XML file that have changed
+since the specified date value (YYYYMMHH).
+.It Fl -cache
+Update the server's timezone database by pulling data from a primary
+timezone server.
+.El
+.Sh EXAMPLES
+Update the server's timezone data from the latest IANA data:
+.Pp
+.Dl "calendarserver_manage_timezones --refesh"
+.Pp
+.Sh FILES
+.Bl -tag -width flag
+.It /etc/caldavd/caldavd.plist
+The Calendar Server configuration file.
+.El
+.Sh SEE ALSO
+.Xr caldavd 8
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/setup.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/setup.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/setup.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -144,7 +144,7 @@
#"bin/calendarserver_manage_postgres",
"bin/calendarserver_manage_principals",
"bin/calendarserver_manage_push",
- #"bin/calendarserver_manage_timezones",
+ "bin/calendarserver_manage_timezones",
"bin/calendarserver_migrate_resources",
#"bin/calendarserver_monitor_amp_notifications",
#"bin/calendarserver_monitor_notifications",
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/support/Apple.make
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/support/Apple.make 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/support/Apple.make 2013-05-15 00:32:59 UTC (rev 11182)
@@ -102,6 +102,7 @@
$(_v) $(INSTALL_FILE) "$(Sources)/doc/calendarserver_purge_principals.8" "$(DSTROOT)$(SIPP)$(MANDIR)/man8"
$(_v) $(INSTALL_FILE) "$(Sources)/doc/calendarserver_manage_push.8" "$(DSTROOT)$(SIPP)$(MANDIR)/man8"
$(_v) $(INSTALL_FILE) "$(Sources)/doc/calendarserver_shell.8" "$(DSTROOT)$(SIPP)$(MANDIR)/man8"
+ $(_v) $(INSTALL_FILE) "$(Sources)/doc/calendarserver_manage_timezones.8" "$(DSTROOT)$(SIPP)$(MANDIR)/man8"
$(_v) gzip -9 -f "$(DSTROOT)$(SIPP)$(MANDIR)/man8/"*.[0-9]
@echo "Installing launchd config..."
$(_v) $(INSTALL_DIRECTORY) "$(DSTROOT)$(NSLOCALDIR)/$(NSLIBRARYSUBDIR)/Server/Calendar and Contacts"
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/scheduling_store/caldav/test/test_resource.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/scheduling_store/caldav/test/test_resource.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/scheduling_store/caldav/test/test_resource.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -158,7 +158,7 @@
@inlineCallbacks
def test_missing_default_vevent_calendar(self):
"""
- Test that pickNewDefaultCalendar will create a missing default calendar.
+ Test that readProperty will not create a missing default calendar.
"""
request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
@@ -174,8 +174,9 @@
names = [calendarName for calendarName in (yield home._newStoreHome.listCalendars())]
self.assertTrue("calendar" not in names)
+ # Property is empty now
default = yield inbox.readProperty(caldavxml.ScheduleDefaultCalendarURL, request)
- self.assertEqual(str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/calendar")
+ self.assertEqual(len(default.children), 0)
yield self.abort()
@@ -183,7 +184,7 @@
@inlineCallbacks
def test_missing_default_vtodo_calendar(self):
"""
- Test that pickNewDefaultCalendar will create a missing default tasks calendar.
+ Test that readProperty will not create a missing default calendar.
"""
request = SimpleStoreRequest(self, "GET", "/calendars/users/wsanchez/")
@@ -199,8 +200,9 @@
names = [calendarName for calendarName in (yield home._newStoreHome.listCalendars())]
self.assertTrue("tasks" not in names)
+ # Property is empty now
default = yield inbox.readProperty(customxml.ScheduleDefaultTasksURL, request)
- self.assertEqual(str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/tasks")
+ self.assertEqual(len(default.children), 0)
yield self.abort()
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/stdconfig.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/stdconfig.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -548,7 +548,7 @@
"TimezoneService" : { # New standard timezone service
"Enabled" : False, # Overall on/off switch
"Mode" : "primary", # Can be "primary" or "secondary"
- "BasePath" : "", # Path to zoneinfo - if None use default package path
+ "BasePath" : "", # Path to directory containing a zoneinfo - if None use default package path
# secondary service MUST define its own writable path
"XMLInfoPath" : "", # Path to db cache info - if None use default package path
# secondary service MUST define its own writable path if
@@ -564,6 +564,7 @@
},
"EnableTimezonesByReference" : False, # Strip out VTIMEZONES that are known
+ "UsePackageTimezones" : False, # Use timezone data from twistedcaldav.zoneinfo - don't copy to Data directory
"EnableBatchUpload" : True, # POST batch uploads
"MaxResourcesBatchUpload" : 100, # Maximum number of resources in a batch POST
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/test_extensions.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/test_extensions.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/test_extensions.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -16,17 +16,18 @@
##
from twext.python.filepath import CachingFilePath as FilePath
-from txdav.xml.element import WebDAVElement, ResourceType
-from txdav.xml.parser import WebDAVDocument
from twext.web2.http_headers import MimeType
from twext.web2.static import MetaDataMixin
from twisted.internet.defer import inlineCallbacks, Deferred, succeed
-from twisted.trial.unittest import TestCase
from twisted.web.microdom import parseString
from twistedcaldav.extensions import DAVFile, DAVResourceWithChildrenMixin, extractCalendarServerPrincipalSearchData
+from twistedcaldav.test.util import TestCase
+from txdav.xml.element import WebDAVElement, ResourceType
+from txdav.xml.parser import WebDAVDocument
+
from xml.etree.cElementTree import XML
class UnicodeProperty(WebDAVElement):
@@ -39,6 +40,7 @@
allowed_children = {}
+
class StrProperty(WebDAVElement):
"""
An element with a unicode name.
@@ -74,7 +76,7 @@
def browserHTML2ETree(htmlString):
"""
Loosely interpret an HTML string as XML and return an ElementTree object for it.
-
+
We're not promising strict XML (in fact, we're specifically saying HTML) in
the content-type of certain responses, but it's much easier to work with
the ElementTree data structures present in Python 2.5+ for testing; so
@@ -222,6 +224,7 @@
self.assertEquals(result[1], ['burger'])
+
class CalendarServerPrincipalSearchTests(TestCase):
def test_extractCalendarServerPrincipalSearchData(self):
"""
@@ -237,13 +240,12 @@
</B:calendarserver-principal-search>
"""
doc = WebDAVDocument.fromString(data)
- tokens, context, applyTo, clientLimit, propElement = extractCalendarServerPrincipalSearchData(doc.root_element)
+ tokens, context, applyTo, clientLimit, _ignore_propElement = extractCalendarServerPrincipalSearchData(doc.root_element)
self.assertEquals(tokens, ["morgen"])
self.assertEquals(context, "attendee")
self.assertFalse(applyTo)
self.assertEquals(clientLimit, None)
-
data = """<B:calendarserver-principal-search xmlns:A="DAV:" xmlns:B="http://calendarserver.org/ns/">
<B:search-token>morgen</B:search-token>
<B:search-token>sagen</B:search-token>
@@ -258,7 +260,7 @@
</B:calendarserver-principal-search>
"""
doc = WebDAVDocument.fromString(data)
- tokens, context, applyTo, clientLimit, propElement = extractCalendarServerPrincipalSearchData(doc.root_element)
+ tokens, context, applyTo, clientLimit, _ignore_propElement = extractCalendarServerPrincipalSearchData(doc.root_element)
self.assertEquals(tokens, ["morgen", "sagen"])
self.assertEquals(context, None)
self.assertTrue(applyTo)
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/test_timezones.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/test_timezones.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/test_timezones.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -15,6 +15,7 @@
##
import twistedcaldav.test.util
+from twistedcaldav.config import config
from twistedcaldav.ical import Component
from twistedcaldav.timezones import TimezoneCache, TimezoneException
from twistedcaldav.timezones import readTZ, listTZs
@@ -33,16 +34,18 @@
def tearDown(self):
TimezoneCache.clear()
TimezoneCache.create()
-
+
+
def doTest(self, filename, dtstart, dtend, testEqual=True):
-
+
if testEqual:
testMethod = self.assertEqual
else:
testMethod = self.assertNotEqual
calendar = Component.fromStream(file(os.path.join(self.data_dir, filename)))
- if calendar.name() != "VCALENDAR": self.fail("Calendar is not a VCALENDAR")
+ if calendar.name() != "VCALENDAR":
+ self.fail("Calendar is not a VCALENDAR")
instances = calendar.expandTimeRanges(PyCalendarDateTime(2100, 1, 1))
for key in instances:
@@ -51,14 +54,15 @@
end = instance.end
testMethod(start, dtstart)
testMethod(end, dtend)
- break;
+ break
+
def test_truncatedApr(self):
"""
- Properties in components
+ Custom VTZ with truncated standard time - 2006. Daylight 2007 OK.
"""
-
- TimezoneCache.create("")
+
+ TimezoneCache.create(empty=True)
TimezoneCache.clear()
self.doTest(
@@ -67,11 +71,13 @@
PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True))
)
+
def test_truncatedDec(self):
"""
- Properties in components
+ Custom VTZ valid from 2007. Daylight 2007 OK.
"""
- TimezoneCache.create("")
+
+ TimezoneCache.create(empty=True)
TimezoneCache.clear()
self.doTest(
@@ -80,12 +86,13 @@
PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True))
)
+
def test_truncatedAprThenDecFail(self):
"""
- Properties in components
+ Custom VTZ with truncated standard time - 2006 loaded first. Daylight 2007 OK, standard 2007 wrong.
"""
- TimezoneCache.create("")
+ TimezoneCache.create(empty=True)
TimezoneCache.clear()
self.doTest(
@@ -100,10 +107,12 @@
testEqual=False
)
+
def test_truncatedAprThenDecOK(self):
"""
- Properties in components
+ VTZ loaded from std timezone DB. 2007 OK.
"""
+
TimezoneCache.create()
self.doTest(
@@ -117,11 +126,13 @@
PyCalendarDateTime(2007, 12, 10, 18, 0, 0, PyCalendarTimezone(utc=True)),
)
+
def test_truncatedDecThenApr(self):
"""
- Properties in components
+ Custom VTZ valid from 2007 loaded first. Daylight 2007 OK.
"""
- TimezoneCache.create("")
+
+ TimezoneCache.create(empty=True)
TimezoneCache.clear()
self.doTest(
@@ -135,6 +146,8 @@
PyCalendarDateTime(2007, 04, 01, 17, 0, 0, PyCalendarTimezone(utc=True))
)
+
+
class TimezoneCacheTest (twistedcaldav.test.util.TestCase):
"""
Timezone support tests
@@ -143,13 +156,14 @@
data_dir = os.path.join(os.path.dirname(__file__), "data")
def test_basic(self):
-
+
TimezoneCache.create()
self.assertTrue(readTZ("America/New_York"))
self.assertTrue(readTZ("US/Eastern"))
+
def test_not_in_cache(self):
-
+
TimezoneCache.create()
data = """BEGIN:VCALENDAR
@@ -183,7 +197,8 @@
"""
calendar = Component.fromString(data)
- if calendar.name() != "VCALENDAR": self.fail("Calendar is not a VCALENDAR")
+ if calendar.name() != "VCALENDAR":
+ self.fail("Calendar is not a VCALENDAR")
instances = calendar.expandTimeRanges(PyCalendarDateTime(2100, 1, 1))
for key in instances:
instance = instances[key]
@@ -191,8 +206,10 @@
end = instance.end
self.assertEqual(start, PyCalendarDateTime(2007, 12, 25, 05, 0, 0, PyCalendarTimezone(utc=True)))
self.assertEqual(end, PyCalendarDateTime(2007, 12, 25, 06, 0, 0, PyCalendarTimezone(utc=True)))
- break;
+ break
+
+
class TimezonePackageTest (twistedcaldav.test.util.TestCase):
"""
Timezone support tests
@@ -201,30 +218,59 @@
def setUp(self):
TimezoneCache.clear()
TimezoneCache.create()
-
+
+
def test_ReadTZ(self):
-
+
self.assertTrue(readTZ("America/New_York").find("TZID:America/New_York") != -1)
self.assertRaises(TimezoneException, readTZ, "America/Pittsburgh")
+
def test_ReadTZCached(self):
-
+
self.assertTrue(readTZ("America/New_York").find("TZID:America/New_York") != -1)
self.assertTrue(readTZ("America/New_York").find("TZID:America/New_York") != -1)
self.assertRaises(TimezoneException, readTZ, "America/Pittsburgh")
self.assertRaises(TimezoneException, readTZ, "America/Pittsburgh")
+
def test_ListTZs(self):
-
+
results = listTZs()
self.assertTrue("America/New_York" in results)
self.assertTrue("Europe/London" in results)
self.assertTrue("GB" in results)
+
def test_ListTZsCached(self):
-
+
results = listTZs()
self.assertTrue("America/New_York" in results)
self.assertTrue("Europe/London" in results)
self.assertTrue("GB" in results)
-
+
+
+ def test_copyPackage(self):
+ """
+ Test that copying of the tz package works.
+ """
+
+ self.patch(config, "UsePackageTimezones", True)
+ TimezoneCache.clear()
+ TimezoneCache.create()
+
+ self.assertFalse(os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
+ self.assertFalse(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "America", "New_York.ics")))
+
+ pkg_tz = readTZ("America/New_York")
+
+ self.patch(config, "UsePackageTimezones", False)
+ TimezoneCache.clear()
+ TimezoneCache.create()
+
+ self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo")))
+ self.assertTrue(os.path.exists(os.path.join(config.DataRoot, "zoneinfo", "America", "New_York.ics")))
+
+ copy_tz = readTZ("America/New_York")
+
+ self.assertEqual(str(pkg_tz), str(copy_tz))
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/util.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/test/util.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -252,6 +252,7 @@
memcacher.Memcacher.allowTestCache = True
memcacher.Memcacher.memoryCacheInstance = None
config.DirectoryAddressBook.Enabled = False
+ config.UsePackageTimezones = True
accounts = FilePath(config.DataRoot).child("accounts.xml")
accounts.setContent(xmlFile.getContent())
@@ -338,6 +339,7 @@
memcacher.Memcacher.allowTestCache = True
memcacher.Memcacher.memoryCacheInstance = None
config.DirectoryAddressBook.Enabled = False
+ config.UsePackageTimezones = True
@property
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/timezones.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/timezones.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/timezones.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -18,6 +18,8 @@
from twext.python.log import Logger
+from twisted.python.filepath import FilePath
+
from twistedcaldav.config import config
from pycalendar.timezonedb import PyCalendarTimezoneDatabase
@@ -47,9 +49,13 @@
class TimezoneException(Exception):
pass
+
+
class TimezoneCache(object):
-
+
dirName = None
+ version = "Unknown"
+ IANA_VERSION_PREFIX = "IANA Timezone Registry: "
@staticmethod
def _getPackageDBPath():
@@ -60,22 +66,86 @@
else:
return pkg_resources.resource_filename("twistedcaldav", "zoneinfo") #@UndefinedVariable
+
@staticmethod
def getDBPath():
if TimezoneCache.dirName is None:
if config.TimezoneService.Enabled and config.TimezoneService.BasePath:
TimezoneCache.dirName = config.TimezoneService.BasePath
+ elif config.UsePackageTimezones:
+ TimezoneCache.dirName = TimezoneCache._getPackageDBPath()
else:
- TimezoneCache.dirName = TimezoneCache._getPackageDBPath()
-
+ TimezoneCache.dirName = os.path.join(config.DataRoot, "zoneinfo")
+
return TimezoneCache.dirName
+
@staticmethod
- def create(dbpath=None):
- TimezoneCache.dirName = dbpath
+ def create(empty=False):
+ """
+ Create a timezone database from the files pointed to by the config. The empty option is used
+ only for testing and will point the DB at an empty directory - i.e., no standard timezones are used.
+
+ @param empty: set to C{True} when doing certain tests that do not want the standard timezone database used.
+ @type empty: C{bool}
+ """
+ if empty:
+ TimezoneCache.dirName = ""
+ else:
+ TimezoneCache.dirName = None
+ TimezoneCache.validatePath()
+ TimezoneCache.version = TimezoneCache.getTZVersion(TimezoneCache.getDBPath())
PyCalendarTimezoneDatabase.createTimezoneDatabase(TimezoneCache.getDBPath())
-
+
+
@staticmethod
+ def getTZVersion(dbpath):
+ try:
+ return open(os.path.join(dbpath, "version.txt")).read().strip()
+ except IOError:
+ return TimezoneCache.IANA_VERSION_PREFIX + "Unknown"
+
+
+ class FilteredFilePath(FilePath):
+ """
+ A FilePath that does a directory copy ignoring dot-prefixed files or directories.
+ """
+
+ def copyFilteredDirectoryTo(self, destination):
+ if self.isdir():
+ if not destination.exists():
+ destination.createDirectory()
+ for child in self.children():
+ if child.basename()[0] != ".":
+ destChild = destination.child(child.basename())
+ child = TimezoneCache.FilteredFilePath(child.path)
+ child.copyFilteredDirectoryTo(destChild)
+ elif self.isfile():
+ self.copyTo(destination)
+
+
+ @staticmethod
+ def validatePath():
+ dbpath = FilePath(TimezoneCache.getDBPath())
+ if not dbpath.exists():
+ # Move package data to the path
+ pkgpath = TimezoneCache.FilteredFilePath(TimezoneCache._getPackageDBPath())
+ log.info("Copying timezones from %s to %s" % (pkgpath.path, dbpath.path,))
+ pkgpath.copyFilteredDirectoryTo(dbpath)
+ else:
+ # Check if pkg is more recent and copy over
+ pkgversion = TimezoneCache.getTZVersion(TimezoneCache._getPackageDBPath())
+ dbversion = TimezoneCache.getTZVersion(dbpath.path)
+ if pkgversion > dbversion:
+ dbpath.remove()
+ pkgpath = TimezoneCache.FilteredFilePath(TimezoneCache._getPackageDBPath())
+ log.info("Updating timezones at %s with %s" % (dbpath.path, pkgpath.path,))
+ pkgpath.copyFilteredDirectoryTo(dbpath)
+ else:
+ log.info("Valid timezones at %s" % (dbpath.path,))
+
+
+ @staticmethod
def clear():
PyCalendarTimezoneDatabase.clearTimezoneDatabase()
@@ -94,6 +164,8 @@
readVTZ(tzid)
return True
+
+
def addVTZ(tzid, tzcal):
"""
Add a VTIMEZONE component to the cache.
@@ -101,37 +173,43 @@
if tzid not in cachedVTZs:
cachedVTZs[tzid] = tzcal
cachedTZs[tzid] = str(tzcal)
-
+
+
+
def readVTZ(tzid):
"""
Try to load the specified TZID as a calendar object from the database. Raise if not found.
"""
if tzid not in cachedVTZs:
-
+
tzcal = PyCalendarTimezoneDatabase.getTimezoneInCalendar(tzid)
if tzcal:
cachedVTZs[tzid] = tzcal
else:
raise TimezoneException("Unknown time zone: %s" % (tzid,))
-
+
return cachedVTZs[tzid]
+
+
def readTZ(tzid):
"""
Try to load the specified TZID as text from the database. Raise if not found.
"""
if tzid not in cachedTZs:
-
+
tzcal = readVTZ(tzid)
if tzcal:
cachedTZs[tzid] = str(tzcal)
else:
raise TimezoneException("Unknown time zone: %s" % (tzid,))
-
+
return cachedTZs[tzid]
+
+
def listTZs(path=""):
"""
List all timezones in the database.
@@ -146,7 +224,7 @@
result.extend(listTZs(os.path.join(path, item)))
elif item.endswith(".ics"):
result.append(os.path.join(path, item[:-4]))
-
+
if not path:
cachedTZIDs.extend(result)
return result
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/timezonestdservice.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/timezonestdservice.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/timezonestdservice.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -98,7 +98,7 @@
self.timezones.createNewDatabase()
else:
self.timezones.readDatabase()
- self.info_source = "Primary"
+ self.info_source = TimezoneCache.version
def _initSecondaryService(self):
@@ -250,6 +250,7 @@
result = {
"info" : {
+ "version": "1",
"primary-source" if self.primary else "secondary_source": self.info_source,
"contacts" : [],
},
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/zoneinfo/version.txt
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/zoneinfo/version.txt 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/zoneinfo/version.txt 2013-05-15 00:32:59 UTC (rev 11182)
@@ -1 +1 @@
-Olson data source: Latest (20130508)
+IANA Timezone Registry: 2013c
\ No newline at end of file
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/base/datastore/subpostgres.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/base/datastore/subpostgres.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/base/datastore/subpostgres.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -85,13 +85,19 @@
def processEnded(self, reason):
- log.warn("postgres process ended %r" % (reason,))
- result = (reason.value.status == 0)
+ log.warn("postgres process ended with status %d" % (reason.value.status,))
+ # If pg_ctl exited with zero, we were successful in starting postgres
+ # If pg_ctl exited with nonzero, we need to give up.
self.lineReceiver.connectionLost(reason)
- self.completionDeferred.callback(result)
+ if reason.value.status == 0:
+ self.completionDeferred.callback(None)
+ else:
+ log.warn("Could not start postgres; see postgres.log")
+ self.completionDeferred.errback(reason)
+
class ErrorOutput(Exception):
"""
The process produced some error output and exited with a non-zero exit
@@ -446,13 +452,14 @@
)
self.monitor = monitor
def gotReady(result):
- log.warn("%s successful" % (pgCtl,))
- self.shouldStopDatabase = result
+ log.warn("%s exited" % (pgCtl,))
+ self.shouldStopDatabase = True
self.ready(*createConnection())
self.deactivateDelayedShutdown()
def reportit(f):
log.err(f)
self.deactivateDelayedShutdown()
+ self.reactor.stop()
self.monitor.completionDeferred.addCallback(
gotReady).addErrback(reportit)
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql.py 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql.py 2013-05-15 00:32:59 UTC (rev 11182)
@@ -1763,12 +1763,10 @@
if child is None:
raise NoSuchHomeChildError()
- #resourceID = child._resourceID
+ resourceID = child._resourceID
yield child.remove()
self._children.pop(name, None)
- # FIX ME: need to keep resourceID around so that default calendars work:
- # see twistedcaldav.scheduling_store.caldav.test.test_resource.DefaultCalendar.test_missing_default_vevent_calendar
- # self._children.pop(resourceID, None)
+ self._children.pop(resourceID, None)
@classproperty
Property changes on: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql.py
___________________________________________________________________
Modified: svn:mergeinfo
- /CalendarServer/branches/config-separation/txdav/common/datastore/sql.py:4379-4443
/CalendarServer/branches/egg-info-351/txdav/common/datastore/sql.py:4589-4625
/CalendarServer/branches/generic-sqlstore/txdav/common/datastore/sql.py:6167-6191
/CalendarServer/branches/new-store/txdav/common/datastore/sql.py:5594-5934
/CalendarServer/branches/new-store-no-caldavfile/txdav/common/datastore/sql.py:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2/txdav/common/datastore/sql.py:5936-5981
/CalendarServer/branches/release/CalendarServer-4.3-dev/txdav/common/datastore/sql.py:10180-10190,10192
/CalendarServer/branches/users/cdaboo/batchupload-6699/txdav/common/datastore/sql.py:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692/txdav/common/datastore/sql.py:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/common/datastore/sql.py:8130-8346
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627/txdav/common/datastore/sql.py:3628-3644
/CalendarServer/branches/users/cdaboo/implicituidrace/txdav/common/datastore/sql.py:8137-8141
/CalendarServer/branches/users/cdaboo/ischedule-dkim/txdav/common/datastore/sql.py:9747-9979
/CalendarServer/branches/users/cdaboo/managed-attachments/txdav/common/datastore/sql.py:9985-10145
/CalendarServer/branches/users/cdaboo/more-sharing-5591/txdav/common/datastore/sql.py:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464/txdav/common/datastore/sql.py:4465-4957
/CalendarServer/branches/users/cdaboo/pods/txdav/common/datastore/sql.py:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar/txdav/common/datastore/sql.py:7085-7206
/CalendarServer/branches/users/cdaboo/pycard/txdav/common/datastore/sql.py:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes/txdav/common/datastore/sql.py:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070/txdav/common/datastore/sql.py:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187/txdav/common/datastore/sql.py:5188-5440
/CalendarServer/branches/users/cdaboo/timezones/txdav/common/datastore/sql.py:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging/txdav/common/datastore/sql.py:8730-8743
/CalendarServer/branches/users/glyph/always-abort-txn-on-error/txdav/common/datastore/sql.py:9958-9969
/CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py:8772-8805
/CalendarServer/branches/users/glyph/conn-limit/txdav/common/datastore/sql.py:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge/txdav/common/datastore/sql.py:4971-5080
/CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect/txdav/common/datastore/sql.py:6824-6876
/CalendarServer/branches/users/glyph/deploybuild/txdav/common/datastore/sql.py:7563-7572
/CalendarServer/branches/users/glyph/digest-auth-redux/txdav/common/datastore/sql.py:10624-10635
/CalendarServer/branches/users/glyph/disable-quota/txdav/common/datastore/sql.py:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres/txdav/common/datastore/sql.py:6592-6614
/CalendarServer/branches/users/glyph/imip-and-admin-html/txdav/common/datastore/sql.py:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client/txdav/common/datastore/sql.py:9054-9105
/CalendarServer/branches/users/glyph/linux-tests/txdav/common/datastore/sql.py:6893-6900
/CalendarServer/branches/users/glyph/migrate-merge/txdav/common/datastore/sql.py:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes/txdav/common/datastore/sql.py:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/sql.py:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7/txdav/common/datastore/sql.py:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete/txdav/common/datastore/sql.py:8321-8330
/CalendarServer/branches/users/glyph/new-export/txdav/common/datastore/sql.py:7444-7485
/CalendarServer/branches/users/glyph/one-home-list-api/txdav/common/datastore/sql.py:10048-10073
/CalendarServer/branches/users/glyph/oracle/txdav/common/datastore/sql.py:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls/txdav/common/datastore/sql.py:7340-7351
/CalendarServer/branches/users/glyph/other-html/txdav/common/datastore/sql.py:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim/txdav/common/datastore/sql.py:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/sql.py:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1/txdav/common/datastore/sql.py:8571-8583
/CalendarServer/branches/users/glyph/q/txdav/common/datastore/sql.py:9560-9688
/CalendarServer/branches/users/glyph/queue-locking-and-timing/txdav/common/datastore/sql.py:10204-10289
/CalendarServer/branches/users/glyph/quota/txdav/common/datastore/sql.py:7604-7637
/CalendarServer/branches/users/glyph/sendfdport/txdav/common/datastore/sql.py:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes/txdav/common/datastore/sql.py:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2/txdav/common/datastore/sql.py:8155-8174
/CalendarServer/branches/users/glyph/sharedpool/txdav/common/datastore/sql.py:6490-6550
/CalendarServer/branches/users/glyph/sharing-api/txdav/common/datastore/sql.py:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones/txdav/common/datastore/sql.py:8524-8535
/CalendarServer/branches/users/glyph/sql-store/txdav/common/datastore/sql.py:5929-6073
/CalendarServer/branches/users/glyph/start-service-start-loop/txdav/common/datastore/sql.py:11060-11065
/CalendarServer/branches/users/glyph/subtransactions/txdav/common/datastore/sql.py:7248-7258
/CalendarServer/branches/users/glyph/table-alias/txdav/common/datastore/sql.py:8651-8664
/CalendarServer/branches/users/glyph/uidexport/txdav/common/datastore/sql.py:7673-7676
/CalendarServer/branches/users/glyph/unshare-when-access-revoked/txdav/common/datastore/sql.py:10562-10595
/CalendarServer/branches/users/glyph/use-system-twisted/txdav/common/datastore/sql.py:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize/txdav/common/datastore/sql.py:9268-9296
/CalendarServer/branches/users/glyph/xattrs-from-files/txdav/common/datastore/sql.py:7757-7769
/CalendarServer/branches/users/sagen/applepush/txdav/common/datastore/sql.py:8126-8184
/CalendarServer/branches/users/sagen/inboxitems/txdav/common/datastore/sql.py:7380-7381
/CalendarServer/branches/users/sagen/locations-resources/txdav/common/datastore/sql.py:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2/txdav/common/datastore/sql.py:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events/txdav/common/datastore/sql.py:6735-6746
/CalendarServer/branches/users/sagen/resource-delegates-4038/txdav/common/datastore/sql.py:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066/txdav/common/datastore/sql.py:4068-4075
/CalendarServer/branches/users/sagen/resources-2/txdav/common/datastore/sql.py:5084-5093
/CalendarServer/branches/users/sagen/testing/txdav/common/datastore/sql.py:10827-10851,10853-10855
/CalendarServer/branches/users/wsanchez/transations/txdav/common/datastore/sql.py:5515-5593
/CalendarServer/trunk/txdav/common/datastore/sql.py:11090-11095,11097-11111,11139-11165
+ /CalendarServer/branches/config-separation/txdav/common/datastore/sql.py:4379-4443
/CalendarServer/branches/egg-info-351/txdav/common/datastore/sql.py:4589-4625
/CalendarServer/branches/generic-sqlstore/txdav/common/datastore/sql.py:6167-6191
/CalendarServer/branches/new-store/txdav/common/datastore/sql.py:5594-5934
/CalendarServer/branches/new-store-no-caldavfile/txdav/common/datastore/sql.py:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2/txdav/common/datastore/sql.py:5936-5981
/CalendarServer/branches/release/CalendarServer-4.3-dev/txdav/common/datastore/sql.py:10180-10190,10192
/CalendarServer/branches/users/cdaboo/batchupload-6699/txdav/common/datastore/sql.py:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692/txdav/common/datastore/sql.py:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes/txdav/common/datastore/sql.py:8130-8346
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627/txdav/common/datastore/sql.py:3628-3644
/CalendarServer/branches/users/cdaboo/implicituidrace/txdav/common/datastore/sql.py:8137-8141
/CalendarServer/branches/users/cdaboo/ischedule-dkim/txdav/common/datastore/sql.py:9747-9979
/CalendarServer/branches/users/cdaboo/managed-attachments/txdav/common/datastore/sql.py:9985-10145
/CalendarServer/branches/users/cdaboo/more-sharing-5591/txdav/common/datastore/sql.py:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464/txdav/common/datastore/sql.py:4465-4957
/CalendarServer/branches/users/cdaboo/pods/txdav/common/datastore/sql.py:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar/txdav/common/datastore/sql.py:7085-7206
/CalendarServer/branches/users/cdaboo/pycard/txdav/common/datastore/sql.py:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes/txdav/common/datastore/sql.py:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070/txdav/common/datastore/sql.py:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187/txdav/common/datastore/sql.py:5188-5440
/CalendarServer/branches/users/cdaboo/timezones/txdav/common/datastore/sql.py:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging/txdav/common/datastore/sql.py:8730-8743
/CalendarServer/branches/users/glyph/always-abort-txn-on-error/txdav/common/datastore/sql.py:9958-9969
/CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py:8772-8805
/CalendarServer/branches/users/glyph/conn-limit/txdav/common/datastore/sql.py:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge/txdav/common/datastore/sql.py:4971-5080
/CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect/txdav/common/datastore/sql.py:6824-6876
/CalendarServer/branches/users/glyph/deploybuild/txdav/common/datastore/sql.py:7563-7572
/CalendarServer/branches/users/glyph/digest-auth-redux/txdav/common/datastore/sql.py:10624-10635
/CalendarServer/branches/users/glyph/disable-quota/txdav/common/datastore/sql.py:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres/txdav/common/datastore/sql.py:6592-6614
/CalendarServer/branches/users/glyph/imip-and-admin-html/txdav/common/datastore/sql.py:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client/txdav/common/datastore/sql.py:9054-9105
/CalendarServer/branches/users/glyph/linux-tests/txdav/common/datastore/sql.py:6893-6900
/CalendarServer/branches/users/glyph/migrate-merge/txdav/common/datastore/sql.py:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes/txdav/common/datastore/sql.py:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6/txdav/common/datastore/sql.py:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7/txdav/common/datastore/sql.py:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete/txdav/common/datastore/sql.py:8321-8330
/CalendarServer/branches/users/glyph/new-export/txdav/common/datastore/sql.py:7444-7485
/CalendarServer/branches/users/glyph/one-home-list-api/txdav/common/datastore/sql.py:10048-10073
/CalendarServer/branches/users/glyph/oracle/txdav/common/datastore/sql.py:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls/txdav/common/datastore/sql.py:7340-7351
/CalendarServer/branches/users/glyph/other-html/txdav/common/datastore/sql.py:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim/txdav/common/datastore/sql.py:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade/txdav/common/datastore/sql.py:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1/txdav/common/datastore/sql.py:8571-8583
/CalendarServer/branches/users/glyph/q/txdav/common/datastore/sql.py:9560-9688
/CalendarServer/branches/users/glyph/queue-locking-and-timing/txdav/common/datastore/sql.py:10204-10289
/CalendarServer/branches/users/glyph/quota/txdav/common/datastore/sql.py:7604-7637
/CalendarServer/branches/users/glyph/sendfdport/txdav/common/datastore/sql.py:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes/txdav/common/datastore/sql.py:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2/txdav/common/datastore/sql.py:8155-8174
/CalendarServer/branches/users/glyph/sharedpool/txdav/common/datastore/sql.py:6490-6550
/CalendarServer/branches/users/glyph/sharing-api/txdav/common/datastore/sql.py:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones/txdav/common/datastore/sql.py:8524-8535
/CalendarServer/branches/users/glyph/sql-store/txdav/common/datastore/sql.py:5929-6073
/CalendarServer/branches/users/glyph/start-service-start-loop/txdav/common/datastore/sql.py:11060-11065
/CalendarServer/branches/users/glyph/subtransactions/txdav/common/datastore/sql.py:7248-7258
/CalendarServer/branches/users/glyph/table-alias/txdav/common/datastore/sql.py:8651-8664
/CalendarServer/branches/users/glyph/uidexport/txdav/common/datastore/sql.py:7673-7676
/CalendarServer/branches/users/glyph/unshare-when-access-revoked/txdav/common/datastore/sql.py:10562-10595
/CalendarServer/branches/users/glyph/use-system-twisted/txdav/common/datastore/sql.py:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize/txdav/common/datastore/sql.py:9268-9296
/CalendarServer/branches/users/glyph/xattrs-from-files/txdav/common/datastore/sql.py:7757-7769
/CalendarServer/branches/users/sagen/applepush/txdav/common/datastore/sql.py:8126-8184
/CalendarServer/branches/users/sagen/inboxitems/txdav/common/datastore/sql.py:7380-7381
/CalendarServer/branches/users/sagen/locations-resources/txdav/common/datastore/sql.py:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2/txdav/common/datastore/sql.py:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events/txdav/common/datastore/sql.py:6735-6746
/CalendarServer/branches/users/sagen/resource-delegates-4038/txdav/common/datastore/sql.py:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066/txdav/common/datastore/sql.py:4068-4075
/CalendarServer/branches/users/sagen/resources-2/txdav/common/datastore/sql.py:5084-5093
/CalendarServer/branches/users/sagen/testing/txdav/common/datastore/sql.py:10827-10851,10853-10855
/CalendarServer/branches/users/wsanchez/transations/txdav/common/datastore/sql.py:5515-5593
/CalendarServer/trunk/txdav/common/datastore/sql.py:11090-11095,11097-11111,11139-11174
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_19_to_20.sql
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_19_to_20.sql 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_19_to_20.sql 2013-05-15 00:32:59 UTC (rev 11182)
@@ -14,9 +14,245 @@
-- limitations under the License.
----
+
---------------------------------------------------
--- Upgrade database schema from VERSION 18 to 19 --
+-- Upgrade database schema from VERSION 19 to 20 --
---------------------------------------------------
--- Now update the version
+----------------
+-- New Tables --
+----------------
+
+-----------------------------
+-- Shared AddressBook Bind --
+-----------------------------
+
+-- Joins sharee ADDRESSBOOK_HOME and owner ADDRESSBOOK_HOME
+
+create table SHARED_ADDRESSBOOK_BIND (
+ ADDRESSBOOK_HOME_RESOURCE_ID integer not null references ADDRESSBOOK_HOME,
+ OWNER_ADDRESSBOOK_HOME_RESOURCE_ID integer not null references ADDRESSBOOK_HOME on delete cascade,
+ ADDRESSBOOK_RESOURCE_NAME varchar(255) not null,
+ BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
+ BIND_STATUS integer not null, -- enum CALENDAR_BIND_STATUS
+ MESSAGE text, -- FIXME: xml?
+
+ primary key (ADDRESSBOOK_HOME_RESOURCE_ID, OWNER_ADDRESSBOOK_HOME_RESOURCE_ID), -- implicit index
+ unique (ADDRESSBOOK_HOME_RESOURCE_ID, ADDRESSBOOK_RESOURCE_NAME) -- implicit index
+);
+
+create index SHARED_ADDRESSBOOK_BIND_RESOURCE_ID on
+ SHARED_ADDRESSBOOK_BIND(OWNER_ADDRESSBOOK_HOME_RESOURCE_ID);
+
+
+-----------------------
+-- Shared Group Bind --
+-----------------------
+
+-- Joins ADDRESSBOOK_HOME and ADDRESSBOOK_OBJECT (kind == group)
+
+create table SHARED_GROUP_BIND (
+ ADDRESSBOOK_HOME_RESOURCE_ID integer not null references ADDRESSBOOK_HOME,
+ GROUP_RESOURCE_ID integer not null references ADDRESSBOOK_OBJECT on delete cascade,
+ GROUP_ADDRESSBOOK_RESOURCE_NAME varchar(255) not null,
+ BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
+ BIND_STATUS integer not null, -- enum CALENDAR_BIND_STATUS
+ MESSAGE text, -- FIXME: xml?
+
+ primary key (ADDRESSBOOK_HOME_RESOURCE_ID, GROUP_RESOURCE_ID), -- implicit index
+ unique (ADDRESSBOOK_HOME_RESOURCE_ID, GROUP_ADDRESSBOOK_RESOURCE_NAME) -- implicit index
+);
+
+create index SHARED_GROUP_BIND_RESOURCE_ID on
+ SHARED_GROUP_BIND(GROUP_RESOURCE_ID);
+
+-----------------------------
+-- AddressBook Object kind --
+-----------------------------
+
+create table ADDRESSBOOK_OBJECT_KIND (
+ ID integer primary key,
+ DESCRIPTION varchar(16) not null unique
+);
+
+insert into ADDRESSBOOK_OBJECT_KIND values (0, 'person');
+insert into ADDRESSBOOK_OBJECT_KIND values (1, 'group' );
+insert into ADDRESSBOOK_OBJECT_KIND values (2, 'resource');
+insert into ADDRESSBOOK_OBJECT_KIND values (3, 'location');
+
+
+---------------------------------
+-- Address Book Object Members --
+---------------------------------
+
+create table ABO_MEMBERS (
+ GROUP_ID integer not null references ADDRESSBOOK_OBJECT on delete cascade, -- AddressBook Object's (kind=='group') RESOURCE_ID
+ ADDRESSBOOK_ID integer not null references ADDRESSBOOK_HOME on delete cascade,
+ MEMBER_ID integer not null references ADDRESSBOOK_OBJECT, -- member AddressBook Object's RESOURCE_ID
+ primary key (GROUP_ID, MEMBER_ID) -- implicit index
+);
+
+
+------------------------------------------
+-- Address Book Object Foreign Members --
+------------------------------------------
+
+create table ABO_FOREIGN_MEMBERS (
+ GROUP_ID integer not null references ADDRESSBOOK_OBJECT on delete cascade, -- AddressBook Object's (kind=='group') RESOURCE_ID
+ ADDRESSBOOK_ID integer not null references ADDRESSBOOK_HOME on delete cascade,
+ MEMBER_ADDRESS varchar(255) not null, -- member AddressBook Object's 'calendar' address
+ primary key (GROUP_ID, MEMBER_ADDRESS) -- implicit index
+);
+
+
+
+-----------------------------
+-- Alter ADDRESSBOOK_HOME --
+-----------------------------
+
+alter table ADDRESSBOOK_HOME
+ add column ADDRESSBOOK_PROPERTY_STORE_ID integer default nextval('RESOURCE_ID_SEQ') not null;
+
+update ADDRESSBOOK_HOME
+ set ADDRESSBOOK_PROPERTY_STORE_ID = (
+ select ADDRESSBOOK_RESOURCE_ID
+ from ADDRESSBOOK_BIND
+ where
+ ADDRESSBOOK_BIND.ADDRESSBOOK_HOME_RESOURCE_ID = ADDRESSBOOK_HOME.RESOURCE_ID and
+ ADDRESSBOOK_BIND.BIND_MODE = 0 and -- CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME = 'addressbook'
+ )
+ where exists (
+ select *
+ from ADDRESSBOOK_BIND
+ where
+ ADDRESSBOOK_BIND.ADDRESSBOOK_HOME_RESOURCE_ID = ADDRESSBOOK_HOME.RESOURCE_ID and
+ ADDRESSBOOK_BIND.BIND_MODE = 0 and -- CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME = 'addressbook'
+ );
+
+
+--------------------------------
+-- change ADDRESSBOOK_OBJECT --
+--------------------------------
+
+alter table ADDRESSBOOK_OBJECT
+ add column KIND integer; -- enum ADDRESSBOOK_OBJECT_KIND
+
+alter table ADDRESSBOOK_OBJECT
+ add column ADDRESSBOOK_HOME_RESOURCE_ID integer references ADDRESSBOOK_HOME on delete cascade;
+
+update ADDRESSBOOK_OBJECT
+ set ADDRESSBOOK_HOME_RESOURCE_ID = (
+ select ADDRESSBOOK_HOME_RESOURCE_ID
+ from ADDRESSBOOK_BIND
+ where
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_ID = ADDRESSBOOK_OBJECT.ADDRESSBOOK_RESOURCE_ID and
+ ADDRESSBOOK_BIND.BIND_MODE = 0 and -- CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME = 'addressbook'
+ ), KIND = 0 -- ADDRESSBOOK_OBJECT_KIND 'person'
+ where exists (
+ select *
+ from ADDRESSBOOK_BIND
+ where
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_ID = ADDRESSBOOK_OBJECT.ADDRESSBOOK_RESOURCE_ID and
+ ADDRESSBOOK_BIND.BIND_MODE = 0 and -- CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME = 'addressbook'
+ );
+
+-- delete rows for shared and non-default address books
+delete
+ from ADDRESSBOOK_OBJECT
+ where exists (
+ select *
+ from ADDRESSBOOK_BIND
+ where
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_ID = ADDRESSBOOK_OBJECT.ADDRESSBOOK_RESOURCE_ID and (
+ ADDRESSBOOK_BIND.BIND_MODE != 0 or -- not CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME != 'addressbook'
+ )
+ );
+
+-- add non null constraints after update and delete are complete
+alter table ADDRESSBOOK_OBJECT
+ alter column KIND
+ set not null;
+
+alter table ADDRESSBOOK_OBJECT
+ alter column ADDRESSBOOK_HOME_RESOURCE_ID
+ set not null;
+
+alter table ADDRESSBOOK_OBJECT
+ drop column ADDRESSBOOK_RESOURCE_ID;
+
+
+------------------------------------------
+-- change ADDRESSBOOK_OBJECT_REVISIONS --
+------------------------------------------
+
+alter table ADDRESSBOOK_OBJECT_REVISIONS
+ add column OWNER_ADDRESSBOOK_HOME_RESOURCE_ID integer references ADDRESSBOOK_HOME;
+
+update ADDRESSBOOK_OBJECT_REVISIONS
+ set OWNER_ADDRESSBOOK_HOME_RESOURCE_ID = (
+ select ADDRESSBOOK_HOME_RESOURCE_ID
+ from ADDRESSBOOK_BIND
+ where
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_ID = ADDRESSBOOK_OBJECT_REVISIONS.ADDRESSBOOK_RESOURCE_ID and
+ ADDRESSBOOK_BIND.BIND_MODE = 0 and -- CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME = 'addressbook'
+ )
+ where exists (
+ select *
+ from ADDRESSBOOK_BIND
+ where
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_ID = ADDRESSBOOK_OBJECT_REVISIONS.ADDRESSBOOK_RESOURCE_ID and
+ ADDRESSBOOK_BIND.BIND_MODE = 0 and -- CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME = 'addressbook'
+ );
+
+-- delete rows for shared and non-default address books
+delete
+ from ADDRESSBOOK_OBJECT_REVISIONS
+ where exists (
+ select *
+ from ADDRESSBOOK_BIND
+ where
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_ID = ADDRESSBOOK_OBJECT_REVISIONS.ADDRESSBOOK_RESOURCE_ID and (
+ ADDRESSBOOK_BIND.BIND_MODE != 0 or -- not CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME != 'addressbook'
+ )
+ );
+
+alter table ADDRESSBOOK_OBJECT_REVISIONS
+ drop column ADDRESSBOOK_RESOURCE_ID;
+
+
+-------------------------------
+-- change RESOURCE_PROPERTY --
+-------------------------------
+
+-- delete rows for shared and non-default address books
+delete
+ from RESOURCE_PROPERTY
+ where exists (
+ select *
+ from ADDRESSBOOK_BIND
+ where
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_ID = RESOURCE_PROPERTY.RESOURCE_ID and (
+ ADDRESSBOOK_BIND.BIND_MODE != 0 or -- not CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME != 'addressbook'
+ )
+ );
+
+
+-------------------------------------
+-- Drop ADDRESSBOOK related tables --
+-------------------------------------
+
+drop table ADDRESSBOOK_METADATA;
+drop table ADDRESSBOOK_BIND;
+drop table ADDRESSBOOK;
+
+-- update schema version
update CALENDARSERVER set VALUE = '20' where NAME = 'VERSION';
Modified: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_19_to_20.sql
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_19_to_20.sql 2013-05-14 23:30:05 UTC (rev 11181)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_19_to_20.sql 2013-05-15 00:32:59 UTC (rev 11182)
@@ -168,7 +168,7 @@
from ADDRESSBOOK_BIND
where
ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_ID = ADDRESSBOOK_OBJECT.ADDRESSBOOK_RESOURCE_ID and (
- ADDRESSBOOK_BIND.BIND_MODE != 0 or -- CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.BIND_MODE != 0 or -- not CALENDAR_BIND_MODE 'own'
ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME != 'addressbook'
)
);
@@ -219,7 +219,7 @@
from ADDRESSBOOK_BIND
where
ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_ID = ADDRESSBOOK_OBJECT_REVISIONS.ADDRESSBOOK_RESOURCE_ID and (
- ADDRESSBOOK_BIND.BIND_MODE != 0 or -- CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.BIND_MODE != 0 or -- not CALENDAR_BIND_MODE 'own'
ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME != 'addressbook'
)
);
@@ -240,7 +240,7 @@
from ADDRESSBOOK_BIND
where
ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_ID = RESOURCE_PROPERTY.RESOURCE_ID and (
- ADDRESSBOOK_BIND.BIND_MODE != 0 or -- CALENDAR_BIND_MODE 'own'
+ ADDRESSBOOK_BIND.BIND_MODE != 0 or -- not CALENDAR_BIND_MODE 'own'
ADDRESSBOOK_BIND.ADDRESSBOOK_RESOURCE_NAME != 'addressbook'
)
);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130514/0716fb98/attachment-0001.html>
More information about the calendarserver-changes
mailing list