Changeset 18:379be4ecdeef


Ignore:
Timestamp:
21.04.2010 16:46:51 (7 years ago)
Author:
hagenbruch@phoibe.ub.rub.de
Branch:
default
Message:

Added caching for the retrieval of consent forms.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mods2solr.py

    r17 r18  
    289289    return (descriptors, subjects) 
    290290 
     291_pnd_cache = {} 
     292 
    291293def _check_consent(pnd): 
    292     resp = urllib.urlopen('http://134.147.247.36:8099/rubauthor/%s/consent' % pnd).read() 
    293     if resp.startswith('Traceback'): # Noch nicht in der Redaktion? 
    294         return 'False' 
     294    if _pnd_cache.get(pnd): 
     295        return _pnd_cache.get(pnd) 
    295296    else: 
    296         return resp 
     297        response = urllib.urlopen('http://134.147.247.36:8099/rubauthor/%s/consent' % pnd)#.read() 
     298        resp = response.read() 
     299        logging.info('CODE: %s' % response.getcode()) 
     300        if response.getcode() == 500: # Noch nicht in der Redaktion? 
     301            _pnd_cache.setdefault(pnd, resp) 
     302            return 'False' 
     303        else: 
     304            _pnd_cache.setdefault(pnd, resp) 
     305            return resp 
    297306 
    298307class Collection(object): 
Note: See TracChangeset for help on using the changeset viewer.