Scrapy, a fast high-level web crawling & scraping framework for Python.
removed Request.context attribute (use Request.meta instead)
Pablo Hoffman8ecc6808e01f
diff --git a/scrapy/trunk/docs/ref/request-response.rst b/scrapy/trunk/docs/ref/request-response.rstindex 49806c3a5..0a9846d24 100644--- a/scrapy/trunk/docs/ref/request-response.rst+++ b/scrapy/trunk/docs/ref/request-response.rst@@ -21,7 +21,7 @@ generated the request.Request objects===============-.. class:: Request(url, callback=None, context=None, method='GET', body=None, headers=None, cookies=None, url_encoding='utf-8', dont_filter=None)+.. class:: Request(url, callback=None, method='GET', body=None, headers=None, cookies=None, url_encoding='utf-8', dont_filter=None)A :class:`Request` object represents an HTTP request, which is usuallygenerated in the Spider and executed by the Downloader, and thus generating@@ -32,9 +32,6 @@ Request objects``callback`` is a function that will be called with the response of thisrequest (once its downloaded) as its first parameter- ``context`` can be a dict which will be accessible in the callback function- in ``response.request.context`` in the callback function-``method`` is a string with the HTTP method of this request``body`` is a string containing the request body or None if the requestdiff --git a/scrapy/trunk/scrapy/contrib/history/middleware.py b/scrapy/trunk/scrapy/contrib/history/middleware.pyindex 18c1ec4a0..1cc3fe0cc 100644--- a/scrapy/trunk/scrapy/contrib/history/middleware.py+++ b/scrapy/trunk/scrapy/contrib/history/middleware.py@@ -31,10 +31,10 @@ class HistoryMiddleware(object):d = datetime.now() - last_checkedif d.days < self.MIN_CHECK_DAYS:raise IgnoreRequest("Not scraping %s (scraped %s ago)" % (request.url, d))- request.context['history_response_version'] = version+ request.meta['history_response_version'] = versiondef process_response(self, request, response, spider):- version = request.context.get('history_response_version')+ version = request.meta.get('history_response_version')if version == self.get_version(response):del request.content['history_response_version']hist = self.historydata.version_info(domain, version)diff --git a/scrapy/trunk/scrapy/http/request.py b/scrapy/trunk/scrapy/http/request.pyindex 850a4772f..c0982c11c 100644--- a/scrapy/trunk/scrapy/http/request.py+++ b/scrapy/trunk/scrapy/http/request.py@@ -17,7 +17,7 @@ from scrapy.utils.defer import chain_deferredclass Request(object):- def __init__(self, url, callback=None, context=None, method='GET',+ def __init__(self, url, callback=None, method='GET',body=None, headers=None, cookies=None,url_encoding='utf-8', dont_filter=None, domain=None):@@ -40,8 +40,6 @@ class Request(object):self.cookies = cookies or {}# request headersself.headers = Headers(headers or {}, encoding=url_encoding)- # persistent context across requests- self.context = context or {}# dont_filter be filtered by schedulerself.dont_filter = dont_filter#allows to directly specify the spider for the request@@ -75,20 +73,18 @@ class Request(object):'headers': self.headers,'cookies': self.cookies,'body': self.body,- 'context': self.context}return "%s(%s)" % (self.__class__.__name__, repr(d))def copy(self):- """Clone request except `context` attribute"""+ """Return a new request cloned from this one"""new = copy.copy(self)new.cache = {}for att in self.__dict__:- if att not in ['cache', 'context', 'url', 'deferred']:+ if att not in ['cache', 'url', 'deferred']:value = getattr(self, att)setattr(new, att, copy.copy(value))new.deferred = defer.Deferred()- new.context = self.context # requests shares same context dictionaryreturn newdef httprepr(self):