#5589 closed (invalid)
Memcache backend should allow retrieval of stored binary objects
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Cache system) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Armin Ronacher, dan@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Currently, the memcache backend is calling smart_unicode() on the output of the cache. This is not correct behavior, as there is no documentation saying that only unicode data can and should be stored in the cache. Theoretically any bytestream should be able to be stored in the cache.
The use case that I am working with in particular is a captcha generator. I was able to store the captcha image data generated with PIL in the cache, but on retrieval, I got a UnicodeDecodeError.
If the unicode restriction is intended, there should be an error on insert as well.
I have a patch to allow binary objects to be retrieved from the memcache backend if the unicode decode fails.
Attachments (1)
Change History (7)
by , 17 years ago
Attachment: | allow_binary_data_in_memcache.diff added |
---|
comment:1 by , 17 years ago
Component: | Uncategorized → Cache system |
---|---|
Has patch: | set |
Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 17 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
Resolution: | → fixed |
Status: | new → closed |
Triage Stage: | Design decision needed → Accepted |
comment:4 by , 17 years ago
Cc: | added |
---|
comment:5 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
The patch behavior is erroneous. The current code tests isinstance(basestring) and will return the value as-is for any other class. So if you want to store a binary object you just need to avoid using strings. Anything that is pickle'able will work.
comment:6 by , 15 years ago
Cc: | added |
---|
I'm not sure the patch behvaior is correct -- isn't that error sometimes useful? -- but indeed arbitrary objects should be storeable.