Logo Search packages:      
Sourcecode: harvestman version File versions  Download package

def HarvestMan::datamgr::harvestManDataManager::is_url_uptodate (   self,
  url,
  filename,
  lmt,
  urldata 
)

New function to check whether the url cache is out
of date by comparing last modified time 

Definition at line 201 of file datamgr.py.

00201                                                           :
        """ New function to check whether the url cache is out
        of date by comparing last modified time """

        # If page caching is not enabled, return False
        # straightaway!
        if not self._cfg.pagecache:
            return (False, False)

        # Assume that cache is not uptodate apriori
        uptodate=False
        fileverified=False

        # Reference to dictionary in the cache list
        cachekey = {}

        d = self._projectcache
        
        if d.has_key(intern(url)):
            cachekey = d[intern(url)]

            cachekey[intern('updated')]=False

            fileloc = cachekey[intern('location')]
            if os.path.exists(fileloc) and os.path.abspath(fileloc) == os.path.abspath(filename):
                fileverified=True

            if cachekey.has_key(intern('last-modified')):
                # Get current modified time
                cmt = cachekey['last-modified']
                # If the latest page has a modified time greater than this
                # page is out of date, otherwise it is uptodate
                if lmt<=cmt:
                    uptodate=True

        # If cache is not updated, update all cache keys
        if not uptodate:
            cachekey[intern('location')] = filename
            cachekey[intern('last-modified')] = lmt
            cachekey[intern('updated')] = True
            if self._cfg.datacache:
                cachekey['data'] = urldata            
                
            self._projectcache[intern(url)] = cachekey
            
        # If both checksums are equal, return True
        # else return False.
        # Modification (Oct 1 2004) - Combine
        # with fileverified boolean.        
        return (uptodate, fileverified)


Generated by  Doxygen 1.6.0   Back to index