Author: russellm
Date: 2010-02-26 09:38:50 -0600 (Fri, 26 Feb 2010)
New Revision: 12603
Modified:
django/branches/releases/1.1.X/django/conf/__init__.py
django/branches/releases/1.1.X/django/conf/project_template/settings.py
django/branches/releases/1.1.X/django/db/backends/postgresql/base.py
django/branches/releases/1.1.X/django/db/backends/postgresql_psycopg2/base.py
django/branches/releases/1.1.X/docs/ref/settings.txt
django/branches/releases/1.1.X/tests/regressiontests/app_loading/tests.py
Log:
[1.1.X] Fixed #1480 -- Added the ability to use the system timezone. Thanks to
Ramiro Morales for the patch.
Backport of r12602 from trunk.
Modified: django/branches/releases/1.1.X/django/conf/__init__.py
===================================================================
--- django/branches/releases/1.1.X/django/conf/__init__.py 2010-02-26
15:33:27 UTC (rev 12602)
+++ django/branches/releases/1.1.X/django/conf/__init__.py 2010-02-26
15:38:50 UTC (rev 12603)
@@ -102,7 +102,7 @@
new_installed_apps.append(app)
self.INSTALLED_APPS = new_installed_apps
- if hasattr(time, 'tzset'):
+ if hasattr(time, 'tzset') and getattr(self, 'TIME_ZONE'):
# Move the time zone info into os.environ. See ticket #2315 for why
# we don't do this unconditionally (breaks Windows).
os.environ['TZ'] = self.TIME_ZONE
Modified:
django/branches/releases/1.1.X/django/conf/project_template/settings.py
===================================================================
--- django/branches/releases/1.1.X/django/conf/project_template/settings.py
2010-02-26 15:33:27 UTC (rev 12602)
+++ django/branches/releases/1.1.X/django/conf/project_template/settings.py
2010-02-26 15:38:50 UTC (rev 12603)
@@ -19,6 +19,8 @@
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
+# On Unix systems, a value of None will cause Django to use the same
+# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
Modified: django/branches/releases/1.1.X/django/db/backends/postgresql/base.py
===================================================================
--- django/branches/releases/1.1.X/django/db/backends/postgresql/base.py
2010-02-26 15:33:27 UTC (rev 12602)
+++ django/branches/releases/1.1.X/django/db/backends/postgresql/base.py
2010-02-26 15:38:50 UTC (rev 12603)
@@ -100,7 +100,7 @@
set_tz = False
settings_dict = self.settings_dict
if self.connection is None:
- set_tz = True
+ set_tz = settings_dict.get('TIME_ZONE')
if settings_dict['DATABASE_NAME'] == '':
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("You need to specify DATABASE_NAME
in your Django settings file.")
Modified:
django/branches/releases/1.1.X/django/db/backends/postgresql_psycopg2/base.py
===================================================================
---
django/branches/releases/1.1.X/django/db/backends/postgresql_psycopg2/base.py
2010-02-26 15:33:27 UTC (rev 12602)
+++
django/branches/releases/1.1.X/django/db/backends/postgresql_psycopg2/base.py
2010-02-26 15:38:50 UTC (rev 12603)
@@ -77,7 +77,7 @@
set_tz = False
settings_dict = self.settings_dict
if self.connection is None:
- set_tz = True
+ set_tz = settings_dict.get('TIME_ZONE')
if settings_dict['DATABASE_NAME'] == '':
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("You need to specify DATABASE_NAME
in your Django settings file.")
Modified: django/branches/releases/1.1.X/docs/ref/settings.txt
===================================================================
--- django/branches/releases/1.1.X/docs/ref/settings.txt 2010-02-26
15:33:27 UTC (rev 12602)
+++ django/branches/releases/1.1.X/docs/ref/settings.txt 2010-02-26
15:38:50 UTC (rev 12603)
@@ -1145,29 +1145,43 @@
Default: ``'America/Chicago'``
-A string representing the time zone for this installation. `See available
choices`_.
-(Note that list of available choices lists more than one on the same line;
-you'll want to use just one of the choices for a given time zone. For instance,
-one line says ``'Europe/London GB GB-Eire'``, but you should use the first bit
-of that -- ``'Europe/London'`` -- as your ``TIME_ZONE`` setting.)
+.. versionchanged:: 1.2
+ ``None`` was added as an allowed value.
-Note that this is the time zone to which Django will convert all dates/times --
-not necessarily the timezone of the server. For example, one server may serve
-multiple Django-powered sites, each with a separate time-zone setting.
+A string representing the time zone for this installation, or
+``None``. `See available choices`_. (Note that list of available
+choices lists more than one on the same line; you'll want to use just
+one of the choices for a given time zone. For instance, one line says
+``'Europe/London GB GB-Eire'``, but you should use the first bit of
+that -- ``'Europe/London'`` -- as your ``TIME_ZONE`` setting.)
-Normally, Django sets the ``os.environ['TZ']`` variable to the time zone you
-specify in the ``TIME_ZONE`` setting. Thus, all your views and models will
-automatically operate in the correct time zone. However, if you're manually
-:ref:`manually configuring settings
-<settings-without-django-settings-module>`, Django will *not* touch the ``TZ``
-environment variable, and it'll be up to you to ensure your processes are
-running in the correct environment.
+Note that this is the time zone to which Django will convert all
+dates/times -- not necessarily the timezone of the server. For
+example, one server may serve multiple Django-powered sites, each with
+a separate time-zone setting.
+Normally, Django sets the ``os.environ['TZ']`` variable to the time
+zone you specify in the ``TIME_ZONE`` setting. Thus, all your views
+and models will automatically operate in the correct time zone.
+However, Django won't set the ``TZ`` environment variable under the
+following conditions:
+
+ * If you're using the manual configuration option as described in
+ :ref:`manually configuring settings
+ <settings-without-django-settings-module>`, or
+
+ * If you specify ``TIME_ZONE = None``. This will cause Django to fall
+ back to using the system timezone.
+
+If Django doesn't set the ``TZ`` environment variable, it's up to you
+to ensure your processes are running in the correct environment.
+
.. note::
- Django cannot reliably use alternate time zones in a Windows environment.
- If you're running Django on Windows, this variable must be set to match the
- system timezone.
+ Django cannot reliably use alternate time zones in a Windows
+ environment. If you're running Django on Windows, this variable
+ must be set to match the system timezone.
+
.. _See available choices:
http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
.. setting:: URL_VALIDATOR_USER_AGENT
Modified:
django/branches/releases/1.1.X/tests/regressiontests/app_loading/tests.py
===================================================================
--- django/branches/releases/1.1.X/tests/regressiontests/app_loading/tests.py
2010-02-26 15:33:27 UTC (rev 12602)
+++ django/branches/releases/1.1.X/tests/regressiontests/app_loading/tests.py
2010-02-26 15:38:50 UTC (rev 12603)
@@ -19,7 +19,7 @@
>>> sys.path = old_sys_path
# Undo a side-effect of installing a new settings object.
->>> if hasattr(time, "tzset"):
+>>> if hasattr(time, "tzset") and old_tz:
... os.environ["TZ"] = old_tz
... time.tzset()
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.