classification
Title: Cookie.Morsel interface needs update
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 3.2
process
Status: languishing Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: a.badger, astronouth7303, eric.araujo, jafo, loewis, r.david.murray
Priority: normal Keywords: easy

Created on 2008-02-29 20:00 by astronouth7303, last changed 2010-05-16 19:36 by eric.araujo.

Messages (6)
msg63144 - (view) Author: Jamie Bliss (astronouth7303) Date: 2008-02-29 20:00
Cookie.Morsel lacks in properly overloading dict methods, amongst other
things:
* .__eq__() does not take .key and .value into account
* .copy() returns a dict, not a Morsel
* .update() allows invalid attributes in, eg
Morsel().update({'eggs':'spam'}) works but Morsel()['eggs'] = 'spam' fails
* .__len__() includes unset keys (why does it set them to an empty string?)
* .__repr__() doesn't print out attributes (path, comment, etc)
* Handling of unicode is fuzzy at best: try Morsel().set(u'eggs\u00bf',
u'\u00f1', u'\00f1'.encode('utf-8'))
* Specifying the idmap and translate function in .set() seems wrong
* Setting .key doesn't check against invalid keys (eg, reserved names)
* The entire Morsel class is undocumented
* There is no way to automatically sync .value and .coded_value
msg63149 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-02-29 23:08
Would you be interested to work on a patch?
msg63329 - (view) Author: Jamie Bliss (astronouth7303) Date: 2008-03-06 18:36
Sure, I'll do that.
msg63331 - (view) Author: Jamie Bliss (astronouth7303) Date: 2008-03-06 19:14
* Should be backwards compatible with people who actually use Morsel
* Didn't even attempt to document it
* Instead of having the Morsel dict being filled initially, unset
attributes are, well, unset
* .key, .value, and .coded_value are now property()s
* .value is considered the actual value (eg, .coded_value is ignore for
__eq__())
msg64203 - (view) Author: Sean Reifschneider (jafo) * (Python committer) Date: 2008-03-20 20:32
I'm going to push this to pending until you can get a patch.  Thanks, Jamie.
msg104581 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-04-29 20:21
This looks like it would be a worthwhile cleanup, and the issue contains useful info to that end, so I'm marking it languishing rather than closing it, in the hopes that someone will pick it up some day.  I also think this could be a nice bug day task for someone, (though it might take all day :), so I'm adding the easy keyword.

(From the sounds of Jamie's second post, he may have thought he uploaded a patch, but didn't...)

Note: I suspect the logic of having 'unset' keys return an empty string is that a Morsel is supposed to have a "fixed set" of keys (and thus those keys should always be there).  I'm not sure that should be changed.
History
Date User Action Args
2010-05-16 19:36:28eric.araujosetnosy: + eric.araujo
2010-04-29 20:21:42r.david.murraysetstatus: pending -> languishing

versions: + Python 3.2, - Python 2.6, Python 2.5
keywords: + easy
nosy: + r.david.murray

messages: + msg104581
stage: test needed
2008-08-04 21:39:33a.badgersetnosy: + a.badger
2008-03-20 20:32:28jafosetstatus: open -> pending
2008-03-20 20:32:20jafosetpriority: normal
nosy: + jafo
messages: + msg64203
2008-03-06 19:14:53astronouth7303setmessages: + msg63331
2008-03-06 18:36:14astronouth7303setmessages: + msg63329
2008-02-29 23:08:02loewissetnosy: + loewis
messages: + msg63149
2008-02-29 20:00:41astronouth7303create