Code

Ticket #1480: t1480-r7662.diff

File t1480-r7662.diff, 4.6 KB (added by ramiro, 6 years ago)

Updated patch so it applies cleanly to trunk as of r7662 and adding New in Django development version note to documentation

Line 
1diff -r 86e9c4dac609 django/conf/__init__.py
2--- a/django/conf/__init__.py   Mon Jun 16 09:38:58 2008 -0300
3+++ b/django/conf/__init__.py   Mon Jun 16 11:39:52 2008 -0300
4@@ -110,7 +110,7 @@
5                 new_installed_apps.append(app)
6         self.INSTALLED_APPS = new_installed_apps
7 
8-        if hasattr(time, 'tzset'):
9+        if hasattr(time, 'tzset') and hasattr(self, 'TIME_ZONE') and self.TIME_ZONE:
10             # Move the time zone info into os.environ. See ticket #2315 for why
11             # we don't do this unconditionally (breaks Windows).
12             os.environ['TZ'] = self.TIME_ZONE
13diff -r 86e9c4dac609 django/conf/project_template/settings.py
14--- a/django/conf/project_template/settings.py  Mon Jun 16 09:38:58 2008 -0300
15+++ b/django/conf/project_template/settings.py  Mon Jun 16 11:39:52 2008 -0300
16@@ -19,6 +19,8 @@
17 # Local time zone for this installation. Choices can be found here:
18 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
19 # although not all choices may be available on all operating systems.
20+# On Unix systems you can leave it undefined or set it to None if
21+# you want the timezone to remain equal to the server's timezone.
22 # If running in a Windows environment this must be set to the same as your
23 # system time zone.
24 TIME_ZONE = 'America/Chicago'
25diff -r 86e9c4dac609 django/db/backends/postgresql/base.py
26--- a/django/db/backends/postgresql/base.py     Mon Jun 16 09:38:58 2008 -0300
27+++ b/django/db/backends/postgresql/base.py     Mon Jun 16 11:39:52 2008 -0300
28@@ -85,7 +85,7 @@
29     def _cursor(self, settings):
30         set_tz = False
31         if self.connection is None:
32-            set_tz = True
33+            set_tz = hasattr(settings, 'TIME_ZONE') and settings.TIME_ZONE
34             if settings.DATABASE_NAME == '':
35                 from django.core.exceptions import ImproperlyConfigured
36                 raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.")
37diff -r 86e9c4dac609 django/db/backends/postgresql_psycopg2/base.py
38--- a/django/db/backends/postgresql_psycopg2/base.py    Mon Jun 16 09:38:58 2008 -0300
39+++ b/django/db/backends/postgresql_psycopg2/base.py    Mon Jun 16 11:39:52 2008 -0300
40@@ -53,7 +53,7 @@
41     def _cursor(self, settings):
42         set_tz = False
43         if self.connection is None:
44-            set_tz = True
45+            set_tz = hasattr(settings, 'TIME_ZONE') and settings.TIME_ZONE
46             if settings.DATABASE_NAME == '':
47                 from django.core.exceptions import ImproperlyConfigured
48                 raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.")
49diff -r 86e9c4dac609 docs/settings.txt
50--- a/docs/settings.txt Mon Jun 16 09:38:58 2008 -0300
51+++ b/docs/settings.txt Mon Jun 16 11:39:52 2008 -0300
52@@ -1058,12 +1058,20 @@
53 not necessarily the timezone of the server. For example, one server may serve
54 multiple Django-powered sites, each with a separate time-zone setting.
55 
56+**New in Django development version:** This setting can also be left undefined
57+or set to ``None`` for deployment scenarios in which you need the timezone to
58+remain in the server's timezone.
59+
60 Normally, Django sets the ``os.environ['TZ']`` variable to the time zone you
61 specify in the  ``TIME_ZONE`` setting. Thus, all your views and models will
62-automatically operate in the correct time zone. However, if you're using the
63-manual configuration option (see below), Django will *not* touch the ``TZ``
64-environment variable, and it'll be up to you to ensure your processes are
65-running in the correct environment.
66+automatically operate in the correct time zone. However, in the following two
67+scenarios:
68+
69+* If you leave the ``TIME_ZONE`` setting undefined or set it to ``None``
70+* If you're using the manual configuration option (see below_)
71+
72+Django will *not* touch the ``TZ`` environment variable, and it'll be up to you
73+to ensure your processes are running in the correct environment.
74 
75 .. note::
76     Django cannot reliably use alternate time zones in a Windows environment.
77@@ -1133,6 +1141,8 @@
78       purely for performance.
79     * Don't reinvent an already-existing setting.
80 
81+.. _below:
82+
83 Using settings without setting DJANGO_SETTINGS_MODULE
84 =====================================================
85 
86@@ -1163,7 +1173,7 @@
87 
88 Consequently, when configured via ``settings.configure()``, Django will not
89 make any modifications to the process environment variables. (See the
90-explanation of ``TIME_ZONE``, above, for why this would normally occur.) It's
91+explanation of TIME_ZONE_, above, for why this would normally occur.) It's
92 assumed that you're already in full control of your environment in these cases.
93 
94 Custom default settings