Opened 16 years ago

Closed 14 years ago

#7770 closed (fixed)

HttpResponse.set_cookie should accept expires=datetime

Reported by: Jeremy Dunck Owned by: Chris Beaven
Component: HTTP handling Version: dev
Severity: Keywords:
Cc: goliath.mailinglist@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

set_cookie accepts a keyword argument, expires, which is expected to be an RFC-formatted string for datetime.

It should (also?) accept a datetime and possibly epoch-seconds.

In general, set_cookie may need to be reviewed for usefulness.

See also: #6657

Attachments (4)

cookie-datetime.diff (1.2 KB ) - added by Ben Firshman 16 years ago.
7770.diff (3.3 KB ) - added by Chris Beaven 16 years ago.
7770.2.diff (4.5 KB ) - added by Chris Beaven 14 years ago.
7770.3.diff (4.6 KB ) - added by Chris Beaven 14 years ago.

Download all attachments as: .zip

Change History (16)

by Ben Firshman, 16 years ago

Attachment: cookie-datetime.diff added

comment:1 by Sung-jin Hong, 16 years ago

Has patch: set
Triage Stage: UnreviewedAccepted

Looks good to me.

comment:2 by David Danier <goliath.mailinglist@…>, 16 years ago

Perhaps max_age could accept a timedelta-object as well? Perhaps even a datetime-object would be possible for max_age (converted to timedelta, converted to seconds)?

comment:3 by David Danier <goliath.mailinglist@…>, 16 years ago

Cc: goliath.mailinglist@… added

comment:4 by Ben Firshman, 16 years ago

Perhaps it should generate both from one argument? They are essentially the same thing. It would be nice if there were default settings for domain, path, secure and expires (as a timedelta?) too.

comment:5 by Malcolm Tredinnick, 16 years ago

milestone: 1.0 alpha

Removing milestone. If we get to it before 1.0, well and good. If not, it's not backwards incompatible, so it could wait until afterwards.

comment:6 by Chris Beaven, 16 years ago

Needs tests: set

Yep, it should definitely generate the max-age (if it wasn't explicitly given).

by Chris Beaven, 16 years ago

Attachment: 7770.diff added

comment:7 by Chris Beaven, 16 years ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

Ok, here's the patch with tests.

I should have done this work when I wrote the custom session age stuff...

comment:8 by Chris Beaven, 16 years ago

Owner: changed from nobody to Chris Beaven
Status: newassigned

comment:9 by Chris Beaven, 14 years ago

Needs documentation: set
Triage Stage: Ready for checkinAccepted

(cough)

by Chris Beaven, 14 years ago

Attachment: 7770.2.diff added

comment:10 by Chris Beaven, 14 years ago

Needs documentation: unset

Added docs, and changed to expect datetime.datetime objects in UTC.

comment:11 by Chris Beaven, 14 years ago

Triage Stage: AcceptedReady for checkin

The latest patch also fixes #13548, and is simplified in that expires only takes a datetime.datetime. If you want to use a datetime.timedelta then you can pass max_age the equivalent seconds.

I'm happy with it. Bumping to RFC

by Chris Beaven, 14 years ago

Attachment: 7770.3.diff added

comment:12 by Malcolm Tredinnick, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [13809]) Allow setting HttpResponse cookie expiry times with datetime objects.

Patch from SmileyChris. Fixed #7770.

Note: See TracTickets for help on using tickets.
Back to Top