Scrapy, a fast high-level web crawling & scraping framework for Python.
ís_cached fix
samus_c9851d8ec91d
diff --git a/scrapy/trunk/scrapy/contrib/downloadermiddleware/cache.py b/scrapy/trunk/scrapy/contrib/downloadermiddleware/cache.pyindex 0211b15dc..d478fbe4b 100644--- a/scrapy/trunk/scrapy/contrib/downloadermiddleware/cache.py+++ b/scrapy/trunk/scrapy/contrib/downloadermiddleware/cache.py@@ -112,7 +112,7 @@ class Cache(object):def is_cached(self, domain, key):pickled_meta = os.path.join(self.requestpath(domain, key), 'pickled_meta')- if os.path.exists(requestpath):+ if os.path.exists(pickled_meta):with open(pickled_meta) as f:metadata = cPickle.load(f)if datetime.datetime.utcnow() <= metadata['timestamp'] + datetime.timedelta(seconds=settings.getint('CACHE2_EXPIRATION_SECS')):@@ -128,10 +128,10 @@ class Cache(object):Return response dictionary if request has correspondent cache record;return None if not."""- requestpath = self.requestpath(domain, key)- if not os.path.exists(requestpath):+ if not self.is_cached(domain, key):return None # not cached+ requestpath = self.requestpath(domain, key)metadata = responsebody = responseheaders = Nonewith open(os.path.join(requestpath, 'pickled_meta')) as f:metadata = cPickle.load(f)diff --git a/scrapy/trunk/scrapy/xpath/selector.py b/scrapy/trunk/scrapy/xpath/selector.pyindex bdc30cf89..0081e2044 100644--- a/scrapy/trunk/scrapy/xpath/selector.py+++ b/scrapy/trunk/scrapy/xpath/selector.py@@ -86,6 +86,10 @@ class XPathSelector(object):class XPathSelectorList(list):"""List of XPathSelector objects"""+ def __getitem__(self, i):+ return '__getitem__'+ #return XPathSelectorList(list.__getslice__(self, i, j))+def x(self, xpath):"""Perform the given XPath query on each XPathSelector of the list andreturn a new (flattened) XPathSelectorList of the results"""