[CalendarServer-changes] [10144] CalendarServer/branches/users/cdaboo/managed-attachments

source_changes at macosforge.org source_changes at macosforge.org
Mon Dec 10 11:20:38 PST 2012


Revision: 10144
          http://trac.calendarserver.org//changeset/10144
Author:   cdaboo at apple.com
Date:     2012-12-10 11:20:38 -0800 (Mon, 10 Dec 2012)
Log Message:
-----------
Merge from trunk.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/webcal/resource.py
    CalendarServer/branches/users/cdaboo/managed-attachments/conf/caldavd-test.plist
    CalendarServer/branches/users/cdaboo/managed-attachments/twistedcaldav/stdconfig.py
    CalendarServer/branches/users/cdaboo/managed-attachments/twistedcaldav/timezonestdservice.py

Added Paths:
-----------
    CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/platform/darwin/test_timezone.py
    CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/platform/darwin/timezone.py

Property Changed:
----------------
    CalendarServer/branches/users/cdaboo/managed-attachments/


Property changes on: CalendarServer/branches/users/cdaboo/managed-attachments
___________________________________________________________________
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/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/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/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/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/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/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/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/wsanchez/transations:5515-5593
/CalendarServer/trunk:9985-10136
   + /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/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/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/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/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/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/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/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/wsanchez/transations:5515-5593
/CalendarServer/trunk:9985-10143

Copied: CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/platform/darwin/test_timezone.py (from rev 10143, CalendarServer/trunk/calendarserver/platform/darwin/test_timezone.py)
===================================================================
--- CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/platform/darwin/test_timezone.py	                        (rev 0)
+++ CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/platform/darwin/test_timezone.py	2012-12-10 19:20:38 UTC (rev 10144)
@@ -0,0 +1,66 @@
+##
+# Copyright (c) 2012 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.
+##
+
+from twistedcaldav.test.util import TestCase
+from twistedcaldav.config import config
+import calendarserver.platform.darwin.timezone
+import twistedcaldav.timezones
+from calendarserver.platform.darwin.timezone import getLocalTimezone, DEFAULT_TIMEZONE
+
+class DefaultTimezoneTests(TestCase):
+
+    def stubLookup(self):
+        return self._storedLookup
+
+    def stubHasTZ(self, ignored):
+        return self._storedHasTZ.pop()
+
+    def setUp(self):
+        self.patch(calendarserver.platform.darwin.timezone,
+            "lookupSystemTimezone", self.stubLookup)
+        self.patch(twistedcaldav.timezones,
+            "hasTZ", self.stubHasTZ)
+
+    def test_getLocalTimezone(self):
+
+        # Empty config, system timezone known = use system timezone
+        self.patch(config, "DefaultTimezone", "")
+        self._storedLookup = "America/New_York"
+        self._storedHasTZ = [True]
+        self.assertEquals(getLocalTimezone(), "America/New_York")
+
+        # Empty config, system timezone unknown = use DEFAULT_TIMEZONE
+        self.patch(config, "DefaultTimezone", "")
+        self._storedLookup = "Unknown/Unknown"
+        self._storedHasTZ = [False]
+        self.assertEquals(getLocalTimezone(), DEFAULT_TIMEZONE)
+
+        # Known config value = use config value
+        self.patch(config, "DefaultTimezone", "America/New_York")
+        self._storedHasTZ = [True]
+        self.assertEquals(getLocalTimezone(), "America/New_York")
+
+        # Unknown config value, system timezone known = use system timezone
+        self.patch(config, "DefaultTimezone", "Unknown/Unknown")
+        self._storedLookup = "America/New_York"
+        self._storedHasTZ = [True, False]
+        self.assertEquals(getLocalTimezone(), "America/New_York")
+
+        # Unknown config value, system timezone unknown = use DEFAULT_TIMEZONE
+        self.patch(config, "DefaultTimezone", "Unknown/Unknown")
+        self._storedLookup = "Unknown/Unknown"
+        self._storedHasTZ = [False, False]
+        self.assertEquals(getLocalTimezone(), DEFAULT_TIMEZONE)

Copied: CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/platform/darwin/timezone.py (from rev 10143, CalendarServer/trunk/calendarserver/platform/darwin/timezone.py)
===================================================================
--- CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/platform/darwin/timezone.py	                        (rev 0)
+++ CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/platform/darwin/timezone.py	2012-12-10 19:20:38 UTC (rev 10144)
@@ -0,0 +1,51 @@
+##
+# Copyright (c) 2012 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.
+##
+
+
+from twistedcaldav.config import config
+import twistedcaldav.timezones
+
+DEFAULT_TIMEZONE = "America/Los_Angeles"
+
+try:
+    from Foundation import NSTimeZone
+    def lookupSystemTimezone():
+        return NSTimeZone.localTimeZone().name().encode("utf-8")
+
+except:
+    def lookupSystemTimezone():
+        return ""
+
+
+def getLocalTimezone():
+    """
+    Returns the default timezone for the server.  The order of precedence is:
+    config.DefaultTimezone, lookupSystemTimezone( ), DEFAULT_TIMEZONE.
+    Also, if neither of the first two values in that list are in the timezone
+    database, DEFAULT_TIMEZONE is returned.
+
+    @return: The server's local timezone name
+    @rtype: C{str}
+    """
+    if config.DefaultTimezone:
+        if twistedcaldav.timezones.hasTZ(config.DefaultTimezone):
+            return config.DefaultTimezone
+
+    systemTimezone = lookupSystemTimezone()
+    if twistedcaldav.timezones.hasTZ(systemTimezone):
+        return systemTimezone
+
+    return DEFAULT_TIMEZONE

Modified: CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/webcal/resource.py
===================================================================
--- CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/webcal/resource.py	2012-12-10 19:15:30 UTC (rev 10143)
+++ CalendarServer/branches/users/cdaboo/managed-attachments/calendarserver/webcal/resource.py	2012-12-10 19:20:38 UTC (rev 10144)
@@ -40,7 +40,9 @@
 
 from twisted.internet.defer import succeed
 
+from calendarserver.platform.darwin.timezone import getLocalTimezone
 
+
 class WebCalendarResource (ReadOnlyResourceMixIn, DAVFile):
 
     def defaultAccessControlList(self):
@@ -152,7 +154,8 @@
         #
         tzid = queryValue("tzid")
         if not tzid:
-            tzid = "America/Los_Angeles"
+            tzid = getLocalTimezone()
+            self.log_debug("Determined timezone to be %s" % (tzid,))
 
         #
         # Make some HTML

Modified: CalendarServer/branches/users/cdaboo/managed-attachments/conf/caldavd-test.plist
===================================================================
--- CalendarServer/branches/users/cdaboo/managed-attachments/conf/caldavd-test.plist	2012-12-10 19:15:30 UTC (rev 10143)
+++ CalendarServer/branches/users/cdaboo/managed-attachments/conf/caldavd-test.plist	2012-12-10 19:20:38 UTC (rev 10144)
@@ -909,6 +909,28 @@
     <key>EnableTimezoneService</key>
     <true/>
 
+    <!-- Standard Timezone Service -->
+    <key>TimezoneService</key>
+    <dict>
+    	<key>Enabled</key>
+    	<true/>
+    	<key>Mode</key>
+    	<string>primary</string>
+    	<key>BasePath</key>
+    	<string></string>
+    	<key>XMLInfoPath</key>
+    	<string></string>
+    	<key>SecondaryService</key>
+    	<dict>
+    		<key>Host</key>
+    		<string></string>
+    		<key>URI</key>
+    		<string></string>
+    		<key>UpdateIntervalMinutes</key>
+    		<integer>1440</integer>
+    	</dict>
+    </dict>
+
     <!-- Batch Upload via POST -->
     <key>EnableBatchUpload</key>
     <true/>

Modified: CalendarServer/branches/users/cdaboo/managed-attachments/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/cdaboo/managed-attachments/twistedcaldav/stdconfig.py	2012-12-10 19:15:30 UTC (rev 10143)
+++ CalendarServer/branches/users/cdaboo/managed-attachments/twistedcaldav/stdconfig.py	2012-12-10 19:20:38 UTC (rev 10144)
@@ -991,6 +991,11 @@
     # during migration
     "MigratedInboxDaysCutoff": 60,
 
+    # The default timezone for the server; on OS X you can leave this empty and the
+    # system's timezone will be used.  If empty and not on OS X it will default to
+    # America/Los_Angeles.
+    "DefaultTimezone" : "",
+
     "Includes": [], # Other plists to parse after this one
 }
 

Modified: CalendarServer/branches/users/cdaboo/managed-attachments/twistedcaldav/timezonestdservice.py
===================================================================
--- CalendarServer/branches/users/cdaboo/managed-attachments/twistedcaldav/timezonestdservice.py	2012-12-10 19:15:30 UTC (rev 10143)
+++ CalendarServer/branches/users/cdaboo/managed-attachments/twistedcaldav/timezonestdservice.py	2012-12-10 19:20:38 UTC (rev 10144)
@@ -820,7 +820,7 @@
                 lastmod = timezone["last-modified"]
                 aliases = timezone.get("aliases", ())
                 timezones[tzid] = TimezoneInfo(tzid, aliases, lastmod, None)
-        except ValueError, KeyError:
+        except (ValueError, KeyError):
             log.debug("Failed to parse JSON timezone list response: %s" % (response.data,))
             returnValue(None)
         log.debug("Got %s timezones from secondary server" % (len(timezones),))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121210/74da4520/attachment-0001.html>


More information about the calendarserver-changes mailing list