Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
- Resource libraries that are required during a retried request are now
Browse files Browse the repository at this point in the history
  correctly registered and injected to the HTML.
  • Loading branch information
Christian Zagrodnick committed Mar 24, 2010
1 parent 371acea commit 68f3f74
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/zc/resourcelibrary/publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,35 @@ def _createResponse(self):
self.resource_libraries = response.resource_libraries = []
return response

def retry(self):
"""Returns request object to be used in a retry attempt.
In addition to BrowswerRequest's retry() the libraries are copied over
to the new request. Otherwise it is not possible to add even new
libraries to a retried request.
>>> import StringIO
>>> request = Request(StringIO.StringIO(), {})
>>> request.resource_libraries = ['foo']
>>> retry_request = request.retry()
>>> retry_request is request
False
>>> request.resource_libraries is retry_request.resource_libraries
True
The assigned libraries are flushed because a new request will define
its own set of required librarires.
>>> request.resource_libraries
[]
"""
request = super(Request, self).retry()
if hasattr(self, 'resource_libraries'):
request.resource_libraries = self.resource_libraries
request.resource_libraries[:] = []
return request


class Response(BrowserResponse):

Expand Down

0 comments on commit 68f3f74

Please sign in to comment.