Changeset 4:e9085ba2bb51 in documentViewer for documentViewer.py


Ignore:
Timestamp:
Jun 16, 2010, 4:38:17 PM (14 years ago)
Author:
casties
Branch:
modularisierung
Message:
  • first fix for timeout issues
  • cleaned logging calls
File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentViewer.py

    r2 r4  
    267267               
    268268        # quote values and assemble into query string
    269         logging.info("XYXXXXX: %s"%repr(params.items()))
     269        logging.debug("XYXXXXX: %s"%repr(params.items()))
    270270        ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()])
    271271        url=self.REQUEST['URL1']+"?"+ps
     
    286286        """returns if access to the resource is granted"""
    287287        access = docinfo.get('accessType', None)
    288         logger("documentViewer (accessOK)", logging.INFO, "access type %s"%access)
     288        logging.debug("documentViewer (accessOK) access type %s"%access)
    289289        if access is not None and access == 'free':
    290             logger("documentViewer (accessOK)", logging.INFO, "access is free")
     290            logging.debug("documentViewer (accessOK) access is free")
    291291            return True
    292292        elif access is None or access in self.authgroups:
     
    299299                return False
    300300       
    301         logger("documentViewer (accessOK)", logging.INFO, "unknown access type %s"%access)
     301        logging.debug("documentViewer (accessOK) unknown access type %s"%access)
    302302        return False
    303303   
     
    315315        infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path
    316316   
    317         logger("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo from %s"%(infoUrl))
     317        logging.debug("documentViewer (getparamfromdigilib) dirInfo from %s"%(infoUrl))
    318318       
    319319        for cnt in range(num_retries):
     
    324324                break
    325325            except:
    326                 logger("documentViewer (getdirinfofromdigilib)", logging.ERROR, "error reading %s (try %d)"%(infoUrl,cnt))
     326                logging.error("documentViewer (getdirinfofromdigilib) error reading %s (try %d)"%(infoUrl,cnt))
    327327        else:
    328328            raise IOError("Unable to get dir-info from %s"%(infoUrl))
    329329       
    330330        sizes=dom.xpath("//dir/size")
    331         logger("documentViewer (getparamfromdigilib)", logging.INFO, "dirInfo:size"%sizes)
     331        logging.debug("documentViewer (getparamfromdigilib) dirInfo:size"%sizes)
    332332       
    333333        if sizes:
     
    364364                break
    365365            except:
    366                 logger("ERROR documentViewer (getIndexMeta)", logging.INFO,"%s (%s)"%sys.exc_info()[0:2])
     366                logging.error("ERROR documentViewer (getIndexMeta) %s (%s)"%sys.exc_info()[0:2])
    367367               
    368368        if dom is None:
     
    392392                break
    393393            except:
    394                 logger("ERROR documentViewer (getPresentationInfoXML)", logging.INFO,"%s (%s)"%sys.exc_info()[0:2])
     394                logging.error("ERROR documentViewer (getPresentationInfoXML) %s (%s)"%sys.exc_info()[0:2])
    395395               
    396396        if dom is None:
     
    402402    def getAuthinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0):
    403403        """gets authorization info from the index.meta file at path or given by dom"""
    404         logger("documentViewer (getauthinfofromindexmeta)", logging.INFO,"path: %s"%(path))
     404        logging.debug("documentViewer (getauthinfofromindexmeta) path: %s"%(path))
    405405       
    406406        access = None
     
    478478    def getDocinfoFromTextTool(self, url, dom=None, docinfo=None):
    479479        """parse texttool tag in index meta"""
    480         logger("documentViewer (getdocinfofromtexttool)", logging.INFO, "url: %s" % (url))
     480        logging.debug("documentViewer (getdocinfofromtexttool) url: %s" % (url))
    481481        if docinfo is None:
    482482           docinfo = {}
     
    493493            archiveName = getTextFromNode(archiveNames[0])
    494494        else:
    495             logger("documentViewer (getdocinfofromtexttool)", logging.WARNING, "resource/name missing in: %s" % (url))
     495            logging.warning("documentViewer (getdocinfofromtexttool) resource/name missing in: %s" % (url))
    496496       
    497497        archivePaths = dom.xpath("//resource/archive-path")
     
    505505        else:
    506506            # try to get archive-path from url
    507             logger("documentViewer (getdocinfofromtexttool)", logging.WARNING, "resource/archive-path missing in: %s" % (url))
     507            logging.warning("documentViewer (getdocinfofromtexttool) resource/archive-path missing in: %s" % (url))
    508508            if (not url.startswith('http')):
    509509                archivePath = url.replace('index.meta', '')
     
    597597    def getDocinfoFromImagePath(self,path,docinfo=None,cut=0):
    598598        """path ist the path to the images it assumes that the index.meta file is one level higher."""
    599         logger("documentViewer (getdocinfofromimagepath)", logging.INFO,"path: %s"%(path))
     599        logging.debug("documentViewer (getdocinfofromimagepath) path: %s"%(path))
    600600        if docinfo is None:
    601601            docinfo = {}
     
    607607        for x in range(cut):       
    608608                path=getParentDir(path)
    609         logging.error("PATH:"+path)
     609        logging.debug("documentViewer (getdocinfofromimagepath) PATH:"+path)
    610610        imageUrl=self.digilibBaseUrl+"/servlet/Scaler?fn="+path
    611611        docinfo['imageURL'] = imageUrl
     
    619619    def getDocinfo(self, mode, url):
    620620        """returns docinfo depending on mode"""
    621         logger("documentViewer (getdocinfo)", logging.INFO,"mode: %s, url: %s"%(mode,url))
     621        logging.debug("documentViewer (getdocinfo) mode: %s, url: %s"%(mode,url))
    622622        # look for cached docinfo in session
    623623        if self.REQUEST.SESSION.has_key('docinfo'):
     
    625625            # check if its still current
    626626            if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url:
    627                 logger("documentViewer (getdocinfo)", logging.INFO,"docinfo in session: %s"%docinfo)
     627                logging.debug("documentViewer (getdocinfo) docinfo in session: %s"%docinfo)
    628628                return docinfo
    629629        # new docinfo
     
    636636            docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1)
    637637        else:
    638             logger("documentViewer (getdocinfo)", logging.ERROR,"unknown mode!")
     638            logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode)
    639639            raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode))
    640640                       
    641         logger("documentViewer (getdocinfo)", logging.INFO,"docinfo: %s"%docinfo)
     641        logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo)
    642642        self.REQUEST.SESSION['docinfo'] = docinfo
    643643        return docinfo
Note: See TracChangeset for help on using the changeset viewer.