mirror of https://github.com/scrapy/scrapy.git
ís_cached fix
--HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%4086
This commit is contained in:
parent
5778ecf15d
commit
c9851d8ec9
|
|
@ -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 = None
|
||||
with open(os.path.join(requestpath, 'pickled_meta')) as f:
|
||||
metadata = cPickle.load(f)
|
||||
|
|
|
|||
|
|
@ -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 and
|
||||
return a new (flattened) XPathSelectorList of the results"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue