Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#15012 closed (fixed)

cache_page decorator (memcached) fails with Django 1.3b1 (can't pickle Input object)

Reported by: vkojouharov@… Owned by: nobody
Component: Generic views Version: 1.3-beta
Severity: Keywords: pickle, memcached, blocker
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello,

I'm consistently getting an error with each request after upgrading from Django 1.3a1 to 1.3b1.
The settings aren't changed after the upgrade, and if I remove the cache_page decorator, everything is back on track. The url in question is pasted below:

url(r'^/?$', cache_page(views.IndexView.as_view(), timeout), name='main_index')

Attachments (4)

cache_page.error (10.7 KB ) - added by vkojouharov@… 13 years ago.
traceback, META and settings
cache_page_test.tar.bz2 (7.1 KB ) - added by urandom 13 years ago.
a simple project which causes the error
t15012.diff (2.6 KB ) - added by Russell Keith-Magee 13 years ago.
Test case demonstrating the problem
15012.diff (5.3 KB ) - added by Joshua "jag" Ginsberg <jag@…> 13 years ago.
Patch to fix the issue (includes previously attached tests)

Download all attachments as: .zip

Change History (11)

by vkojouharov@…, 13 years ago

Attachment: cache_page.error added

traceback, META and settings

comment:1 by Russell Keith-Magee, 13 years ago

Resolution: worksforme
Status: newclosed

We're going to need a bit more than a stack trace. We have an test suite checking cache_page, and those tests are passing. There is clearly something special about your page.

We need a reproducible test case to be able to accept this bug. Please reopen if you can provide a simple view that fails in the way you describe.

by urandom, 13 years ago

Attachment: cache_page_test.tar.bz2 added

a simple project which causes the error

comment:2 by urandom, 13 years ago

Resolution: worksforme
Status: closedreopened

I've attached a generic django project, with an app that only contains 1 view that is cached. The only setting that was changed was the cache setting. The apache directory contains the wsgi and virtualhost configs for apache.

Running this through apache reproduces this error. Interestingly, running it through the internal server produces a different error, which is still connected to the cache_page:

a class that defines __slots__ without defining __getstate__ cannot be pickled

comment:3 by Russell Keith-Magee, 13 years ago

Component: Cache systemGeneric views
Triage Stage: UnreviewedDesign decision needed

Ah. This is a bit of a problem. The introduction of TemplateResponse means that the cache page decorator can't be used on Template Views. Which is a fairly major omission.

We either need to make generic views use normal responses (and make TemplateResponse an available option), or we need to find a way to let decorators (especially the cache decorator) play nice with TemplateResponse.

This is definitely a 1.3 blocker.

by Russell Keith-Magee, 13 years ago

Attachment: t15012.diff added

Test case demonstrating the problem

comment:4 by Russell Keith-Magee, 13 years ago

Keywords: blocker added

by Joshua "jag" Ginsberg <jag@…>, 13 years ago

Attachment: 15012.diff added

Patch to fix the issue (includes previously attached tests)

comment:5 by Joshua "jag" Ginsberg <jag@…>, 13 years ago

Has patch: set

Attached a patch - it puts pre_render and post_render callbacks into the TemplateResponse and modifies the cache middleware, in the face of a TemplateResponse, to register a callback on the TemplateResponse to store the final rendered copy in cache. I included russelm's test cases in the patch.

-jag

comment:6 by Russell Keith-Magee, 13 years ago

Resolution: fixed
Status: reopenedclosed

(In [15295]) Fixed #15012 -- Added post-rendering callbacks to TemplateResponse so that decorators (in particular, the cache decorator) can defer processing until after rendering has occurred. Thanks to Joshua Ginsberg for the draft patch.

comment:7 by Jacob, 12 years ago

milestone: 1.3

Milestone 1.3 deleted

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