Ticket #1480: 1480-r12590.diff

File 1480-r12590.diff, 6.4 KB (added by Ramiro Morales, 15 years ago)

Patch updated to r12590 (fixed docs merge conflict)

  • django/conf/__init__.py

    diff --git a/django/conf/__init__.py b/django/conf/__init__.py
    a b  
    102102                new_installed_apps.append(app)
    103103        self.INSTALLED_APPS = new_installed_apps
    104104
    105         if hasattr(time, 'tzset'):
     105        if hasattr(time, 'tzset') and hasattr(self, 'TIME_ZONE') and bool(self.TIME_ZONE):
    106106            # Move the time zone info into os.environ. See ticket #2315 for why
    107107            # we don't do this unconditionally (breaks Windows).
    108108            os.environ['TZ'] = self.TIME_ZONE
  • django/conf/project_template/settings.py

    diff --git a/django/conf/project_template/settings.py b/django/conf/project_template/settings.py
    a b  
    2323# Local time zone for this installation. Choices can be found here:
    2424# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
    2525# although not all choices may be available on all operating systems.
     26# On Unix systems you can set it to None if you want Django don't
     27# touch the timezone at all so it stays equal to the server's timezone.
    2628# If running in a Windows environment this must be set to the same as your
    2729# system time zone.
    2830TIME_ZONE = 'America/Chicago'
  • django/db/backends/postgresql/base.py

    diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
    a b  
    119119        set_tz = False
    120120        settings_dict = self.settings_dict
    121121        if self.connection is None:
    122             set_tz = True
     122            new_conn = True
     123            set_tz = hasattr(settings, 'TIME_ZONE') and bool(settings.TIME_ZONE)
    123124            if settings_dict['NAME'] == '':
    124125                from django.core.exceptions import ImproperlyConfigured
    125126                raise ImproperlyConfigured("You need to specify NAME in your Django settings file.")
     
    136137            self.connection.set_isolation_level(1) # make transactions transparent to all cursors
    137138            connection_created.send(sender=self.__class__)
    138139        cursor = self.connection.cursor()
    139         if set_tz:
    140             cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
     140        if new_conn:
     141            if set_tz:
     142                cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
    141143            if not hasattr(self, '_version'):
    142144                self.__class__._version = get_version(cursor)
    143145            if self._version[0:2] < (8, 0):
  • django/db/backends/postgresql_psycopg2/base.py

    diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
    a b  
    110110        self.validation = BaseDatabaseValidation(self)
    111111
    112112    def _cursor(self):
     113        new_conn = False
    113114        set_tz = False
    114115        settings_dict = self.settings_dict
    115116        if self.connection is None:
    116             set_tz = True
     117            new_conn = True
     118            set_tz = hasattr(settings, 'TIME_ZONE') and bool(settings.TIME_ZONE)
    117119            if settings_dict['NAME'] == '':
    118120                from django.core.exceptions import ImproperlyConfigured
    119121                raise ImproperlyConfigured("You need to specify NAME in your Django settings file.")
     
    137139            connection_created.send(sender=self.__class__)
    138140        cursor = self.connection.cursor()
    139141        cursor.tzinfo_factory = None
    140         if set_tz:
    141             cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
     142        if new_conn:
     143            if set_tz:
     144                cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
    142145            if not hasattr(self, '_version'):
    143146                self.__class__._version = get_version(cursor)
    144147            if self._version[0:2] < (8, 0):
  • docs/ref/settings.txt

    diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
    a b  
    15051505
    15061506Default: ``'America/Chicago'``
    15071507
    1508 A string representing the time zone for this installation. `See available choices`_.
    1509 (Note that list of available choices lists more than one on the same line;
    1510 you'll want to use just one of the choices for a given time zone. For instance,
    1511 one line says ``'Europe/London GB GB-Eire'``, but you should use the first bit
    1512 of that -- ``'Europe/London'`` -- as your ``TIME_ZONE`` setting.)
     1508A string representing the time zone for this installation or ``None``. `See
     1509available choices`_.  (Note that list of available choices lists more than one
     1510on the same line; you'll want to use just one of the choices for a given time
     1511zone. For instance, one line says ``'Europe/London GB GB-Eire'``, but you should
     1512use the first bit of that -- ``'Europe/London'`` -- as your ``TIME_ZONE``
     1513setting.)
    15131514
    15141515Note that this is the time zone to which Django will convert all dates/times --
    15151516not necessarily the timezone of the server. For example, one server may serve
    15161517multiple Django-powered sites, each with a separate time-zone setting.
    15171518
     1519If the ``None`` value is used for this setting. Django will refrain from
     1520setting the timezone and the server system timezone will be used instead.
     1521
    15181522Normally, Django sets the ``os.environ['TZ']`` variable to the time zone you
    15191523specify in the ``TIME_ZONE`` setting. Thus, all your views and models will
    1520 automatically operate in the correct time zone. However, if you're manually
    1521 :ref:`manually configuring settings
    1522 <settings-without-django-settings-module>`, Django will *not* touch the ``TZ``
    1523 environment variable, and it'll be up to you to ensure your processes are
    1524 running in the correct environment.
     1524automatically operate in the correct time zone. However, in the following two
     1525scenarios:
     1526
     1527* If you set this setting to ``None``, as described above
     1528* If you're using the manual configuration option as described in
     1529  :ref:`manually configuring settings <settings-without-django-settings-module>`
     1530
     1531Django will *not* touch the ``TZ`` environment variable, and it'll be up to you
     1532to ensure your processes are running in the correct environment.
    15251533
    15261534.. note::
    15271535    Django cannot reliably use alternate time zones in a Windows environment.
    15281536    If you're running Django on Windows, this variable must be set to match the
    15291537    system timezone.
    15301538
     1539.. versionadded:: 1.2
     1540    The possibility to set the value of this setting to ``None`` was added.
     1541
    15311542.. _See available choices: http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
    15321543
    15331544.. setting:: URL_VALIDATOR_USER_AGENT
Back to Top