# HG changeset patch # User Julien Cristau # Date 1426520794 -3600 # Node ID 937deb71a681045f9f84b72e5388a8718114ead6 # Parent b6c55274135aa46a82f4dd274146db48acec490b [web] kill GMTOFFSET (closes #2154655) Its last user, set_cookie(expires=...), can just as well interpret its argument as UTC. Naïve datetime objects with an implicit non-UTC timezone are just awful. diff -r b6c55274135a -r 937deb71a681 doc/3.21.rst --- a/doc/3.21.rst Thu Mar 26 08:34:47 2015 +0100 +++ b/doc/3.21.rst Mon Mar 16 16:46:34 2015 +0100 @@ -9,6 +9,14 @@ .. _cube: https://www.cubicweb.org/project/cubicweb-timeline +API changes +----------- + +* req.set_cookie's "expires" argument, if not None, is expected to be a + date or a datetime in UTC. It was previously interpreted as localtime + with the UTC offset the server started in, which was inconsistent (we + are not aware of any users of that API). + Deprecated code drops --------------------- diff -r b6c55274135a -r 937deb71a681 web/httpcache.py --- a/web/httpcache.py Thu Mar 26 08:34:47 2015 +0100 +++ b/web/httpcache.py Mon Mar 16 16:46:34 2015 +0100 @@ -22,10 +22,6 @@ from time import mktime from datetime import datetime -# time delta usable to convert localized time to GMT time -# XXX this become erroneous after a DST transition!!! -GMTOFFSET = - (datetime.now() - datetime.utcnow()) - class NoHTTPCacheManager(object): """default cache manager: set no-cache cache control policy""" def __init__(self, view): diff -r b6c55274135a -r 937deb71a681 web/request.py --- a/web/request.py Thu Mar 26 08:34:47 2015 +0100 +++ b/web/request.py Mon Mar 16 16:46:34 2015 +0100 @@ -45,7 +45,7 @@ from cubicweb.view import TRANSITIONAL_DOCTYPE_NOEXT from cubicweb.web import (INTERNAL_FIELD_VALUE, LOGGER, NothingToEdit, RequestError, StatusResponse) -from cubicweb.web.httpcache import GMTOFFSET, get_validators +from cubicweb.web.httpcache import get_validators from cubicweb.web.http_headers import Headers, Cookie, parseDateTime _MARKER = object() @@ -536,8 +536,8 @@ # we don't want to handle times before the EPOCH (cause bug on # windows). Also use > and not >= else expires == 0 and Cookie think # that means no expire... - assert expires + GMTOFFSET > date(1970, 1, 1) - expires = timegm((expires + GMTOFFSET).timetuple()) + assert expires > date(1970, 1, 1) + expires = timegm(expires.timetuple()) else: expires = None # make sure cookie is set on the correct path