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)
Change History (16)
by , 16 years ago
Attachment: | cookie-datetime.diff added |
---|
comment:1 by , 16 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 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 , 16 years ago
Cc: | added |
---|
comment:4 by , 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 , 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 , 16 years ago
Needs tests: | set |
---|
Yep, it should definitely generate the max-age
(if it wasn't explicitly given).
by , 16 years ago
comment:7 by , 16 years ago
Needs tests: | unset |
---|---|
Triage Stage: | Accepted → Ready 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 , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:9 by , 14 years ago
Needs documentation: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
(cough)
by , 14 years ago
Attachment: | 7770.2.diff added |
---|
comment:10 by , 14 years ago
Needs documentation: | unset |
---|
Added docs, and changed to expect datetime.datetime objects in UTC.
comment:11 by , 14 years ago
Triage Stage: | Accepted → Ready 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 , 14 years ago
Attachment: | 7770.3.diff added |
---|
comment:12 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Looks good to me.