2012-03-13 14:59:04 +08:00
|
|
|
from django.conf import settings
|
|
|
|
from django.db import close_connection
|
2008-08-06 23:32:46 +08:00
|
|
|
from django.dispatch import Signal
|
|
|
|
|
|
|
|
template_rendered = Signal(providing_args=["template", "context"])
|
2011-05-18 20:08:53 +08:00
|
|
|
|
|
|
|
setting_changed = Signal(providing_args=["setting", "value"])
|
2012-03-13 14:59:04 +08:00
|
|
|
|
|
|
|
# Close the database connection to re-establish it with the proper time zone.
|
|
|
|
def close_connection_on_time_zone_change(**kwargs):
|
|
|
|
if (kwargs['setting'] == 'USE_TZ'
|
|
|
|
or (kwargs['setting'] == 'TIME_ZONE' and not settings.USE_TZ)):
|
|
|
|
close_connection()
|
|
|
|
setting_changed.connect(close_connection_on_time_zone_change)
|