Scrapy, a fast high-level web crawling & scraping framework for Python.
dropped "cache" attribute of Request and Response objects
Pablo Hoffman31693eb90fad
diff --git a/docs/topics/request-response.rst b/docs/topics/request-response.rstindex 49ab5a20f..177e1e65c 100644--- a/docs/topics/request-response.rst+++ b/docs/topics/request-response.rst@@ -131,29 +131,17 @@ Request objects.. _shallow copied: http://docs.python.org/library/copy.html- .. attribute:: Request.cache-- A dict that contains arbitrary cached data for this request. This dict is- empty for new Requests, and is usually populated by different Scrapy- components (extensions, middlewares, etc) to avoid duplicate processing. So- the data contained in this dict depends on the extensions you have enabled.-- Unlike the ``meta`` attribute, this dict is not copied at all when the- request is cloned using the ``copy()`` or ``replace()`` methods.-.. method:: Request.copy()- Return a new Request which is a copy of this Request. The attribute- :attr:`Request.meta` is copied, while :attr:`Request.cache` is not. See- also :ref:`topics-request-response-ref-request-callback-arguments`.+ Return a new Request which is a copy of this Request. See also:+ :ref:`topics-request-response-ref-request-callback-arguments`... method:: Request.replace([url, callback, method, headers, body, cookies, meta, encoding, dont_filter])Return a Request object with the same members, except for those membersgiven new values by whichever keyword arguments are specified. Theattribute :attr:`Request.meta` is copied by default (unless a new value- is given in the ``meta`` argument). The :attr:`Request.cache` attribute- is always cleared. See also+ is given in the ``meta`` argument). See also:ref:`topics-request-response-ref-request-callback-arguments`... _topics-request-response-ref-callback-copy:@@ -415,24 +403,16 @@ Response objectsthey're shown on the string representation of the Response (`__str__`method) which is used by the engine for logging.- .. attribute:: Response.cache-- A dict that contains arbitrary cached data for this response, similar to- the :attr:`Request.cache` attribute. See the :attr:`Request.cache`- attribute for more info.-.. method:: Response.copy()- Return a new Response which is a copy of this Response. The attribute- :attr:`Response.meta` is copied, while :attr:`Response.cache` is not.+ Return a new Response which is a copy of this Response... method:: Response.replace([url, status, headers, body, meta, flags, cls])Return a Response object with the same members, except for those membersgiven new values by whichever keyword arguments are specified. Theattribute :attr:`Response.meta` is copied by default (unless a new value- is given in the ``meta`` argument). The :attr:`Response.cache`- attribute is always cleared.+ is given in the ``meta`` argument)... _topics-request-response-ref-response-subclasses:diff --git a/scrapy/http/request/__init__.py b/scrapy/http/request/__init__.pyindex cc86b6f5a..df8c0105c 100644--- a/scrapy/http/request/__init__.py+++ b/scrapy/http/request/__init__.py@@ -15,7 +15,7 @@ from scrapy.utils.trackref import object_refclass Request(object_ref):- __slots__ = ['_encoding', 'method', '_url', '_body', '_meta', '_cache', \+ __slots__ = ['_encoding', 'method', '_url', '_body', '_meta', \'dont_filter', 'headers', 'cookies', 'deferred', 'priority', \'__weakref__']@@ -38,7 +38,6 @@ class Request(object_ref):self.dont_filter = dont_filterself._meta = dict(meta) if meta else None- self._cache = None@propertydef meta(self):@@ -46,12 +45,6 @@ class Request(object_ref):self._meta = {}return self._meta- @property- def cache(self):- if self._cache is None:- self._cache = {}- return self._cache-def _get_url(self):return self._urldiff --git a/scrapy/http/response/__init__.py b/scrapy/http/response/__init__.pyindex 000b710e7..cb6b8d776 100644--- a/scrapy/http/response/__init__.py+++ b/scrapy/http/response/__init__.py@@ -13,7 +13,7 @@ from scrapy.utils.trackref import object_refclass Response(object_ref):__slots__ = ['url', 'headers', 'status', '_body', 'request', '_meta', \- 'flags', '_cache', '__weakref__']+ 'flags', '__weakref__']def __init__(self, url, status=200, headers=None, body='', meta=None, flags=None):self.url = url@@ -23,7 +23,6 @@ class Response(object_ref):self.request = Noneself.flags = [] if flags is None else list(flags)self._meta = dict(meta) if meta else None- self._cache = None@propertydef meta(self):@@ -31,12 +30,6 @@ class Response(object_ref):self._meta = {}return self._meta- @property- def cache(self):- if self._cache is None:- self._cache = {}- return self._cache-def _get_body(self):return self._bodydiff --git a/scrapy/tests/test_http_request.py b/scrapy/tests/test_http_request.pyindex ecf94100a..6041f3063 100644--- a/scrapy/tests/test_http_request.py+++ b/scrapy/tests/test_http_request.py@@ -118,12 +118,8 @@ class RequestTest(unittest.TestCase):r1 = Request("http://www.example.com", callback=somecallback)r1.meta['foo'] = 'bar'- r1.cache['lala'] = 'lolo'r2 = r1.copy()- assert r1.cache- assert not r2.cache-assert r1.deferred is not r2.deferred# make sure meta dict is shallow copied@@ -288,12 +284,8 @@ class XmlRpcRequestTest(unittest.TestCase):r1 = XmlRpcRequest("http://www.example.com", callback=somecallback,methodname='login', params=('username', 'password'))r1.meta['foo'] = 'bar'- r1.cache['lala'] = 'lolo'r2 = r1.copy()- assert r1.cache- assert not r2.cache-assert r1.deferred is not r2.deferred# make sure meta dict is shallow copieddiff --git a/scrapy/tests/test_http_response.py b/scrapy/tests/test_http_response.pyindex ccf5ae6cc..e0ca7df43 100644--- a/scrapy/tests/test_http_response.py+++ b/scrapy/tests/test_http_response.py@@ -46,15 +46,11 @@ class ResponseTest(unittest.TestCase):r1 = Response("http://www.example.com", body="Some body")r1.meta['foo'] = 'bar'r1.flags.append('cached')- r1.cache['lala'] = 'lolo'r2 = r1.copy()self.assertEqual(r1.status, r2.status)self.assertEqual(r1.body, r2.body)- assert r1.cache- assert not r2.cache-# make sure meta dict is shallow copiedassert r1.meta is not r2.meta, "meta must be a shallow copy, not identical"self.assertEqual(r1.meta, r2.meta)diff --git a/scrapy/tests/test_utils_python.py b/scrapy/tests/test_utils_python.pyindex 38796436d..13d8be30c 100644--- a/scrapy/tests/test_utils_python.py+++ b/scrapy/tests/test_utils_python.py@@ -32,8 +32,6 @@ class UtilsPythonTestCase(unittest.TestCase):def test_memoizemethod_noargs(self):class A(object):- def __init__(self):- self.cache = {}@memoizemethod_noargsdef cached(self):