ís_cached fix

--HG--
extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%4086
This commit is contained in:
samus_ 2008-07-22 16:11:57 +00:00
parent 5778ecf15d
commit c9851d8ec9
2 changed files with 7 additions and 3 deletions

View File

@ -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)

View File

@ -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"""