Diff for /zogiLib/zogiLib.py between versions 1.32 and 1.35

version 1.32, 2004/07/19 16:31:46 version 1.35, 2004/07/22 17:19:22
Line 14  import urllib Line 14  import urllib
 import types  import types
 from Globals import package_home  from Globals import package_home
   
 ZOGIVERSION = "0.9.5 ROC:25.6.2004"  ZOGIVERSION = "0.9.7 ROC:21.7.2004"
   
 def cropf(f):  def cropf(f):
     """returns a float with reduced precision"""      """returns a float with reduced precision"""
Line 388  class zogiLib(Folder): Line 388  class zogiLib(Folder):
             {'label':'Main Config','action':'changeZogiLibForm'},              {'label':'Main Config','action':'changeZogiLibForm'},
             )              )
   
     def __init__(self, id, title, digilibBaseUrl,localFileBase, version="book", basePath="", dlTarget=None):      def __init__(self, id, title, dlServerURL,localFileBase, version="book", basePath="", dlTarget=None):
         """init"""          """init"""
   
         self.id=id          self.id=id
         self.title=title          self.title=title
         self.digilibBaseUrl=digilibBaseUrl          self.dlServerURL = dlServerURL
   
         self.localFileBase=localFileBase          self.localFileBase=localFileBase
         self.basePath=basePath          self.basePath=basePath
Line 410  class zogiLib(Folder): Line 410  class zogiLib(Folder):
     def getContextStatic(self):      def getContextStatic(self):
         """get all the contexts which go to static pages"""          """get all the contexts which go to static pages"""
                   
           try:
         dom=xml.dom.minidom.parse(urllib.urlopen(self.getMetaFileName()))          dom=xml.dom.minidom.parse(urllib.urlopen(self.getMetaFileName()))
         contexts=dom.getElementsByTagName("context")          contexts=dom.getElementsByTagName("context")
   
Line 422  class zogiLib(Folder): Line 422  class zogiLib(Folder):
             if name or link:              if name or link:
                 ret.append((name,link))                  ret.append((name,link))
         return ret          return ret
           except:
               return []
   
     def getContextDatabases(self):      def getContextDatabases(self):
         """get all dynamic contexts"""          """get all dynamic contexts"""
           try:
         dom=xml.dom.minidom.parse(urllib.urlopen(self.getMetaFileName()))          dom=xml.dom.minidom.parse(urllib.urlopen(self.getMetaFileName()))
         contexts=dom.getElementsByTagName("context")          contexts=dom.getElementsByTagName("context")
         ret=[]          ret=[]
Line 444  class zogiLib(Folder): Line 447  class zogiLib(Folder):
                     ret.append((db,link))                      ret.append((db,link))
                                           
         return ret          return ret
           except:
               return ret
   
     def formatHTML(self,url,label=None,viewUrl=None):      def formatHTML(self,url,label=None,viewUrl=None):
   
Line 468  class zogiLib(Folder): Line 473  class zogiLib(Folder):
           
     def getMetaData(self):      def getMetaData(self):
         """getMetaData"""          """getMetaData"""
           try:
         dom=xml.dom.minidom.parse(urllib.urlopen(self.getMetaFileName()))          dom=xml.dom.minidom.parse(urllib.urlopen(self.getMetaFileName()))
           except:
               return "error metadata"
           
         contexts=dom.getElementsByTagName("context")          contexts=dom.getElementsByTagName("context")
         ret=[]          ret=[]
         db=self.getDLParam("db")          db=self.getDLParam("db")
Line 511  class zogiLib(Folder): Line 520  class zogiLib(Folder):
     def getDLInfo(self):      def getDLInfo(self):
         """get DLInfo from digilib server"""          """get DLInfo from digilib server"""
         paramH={}          paramH={}
         baseUrl=re.sub("servlet/Scaler","dlInfo-xml.jsp",self.digilibBaseUrl)          baseUrl=self.dlServerURL+"/dlInfo-xml.jsp"
         try:          try:
             url=urllib.urlopen(baseUrl+self.REQUEST['QUERY_STRING'])              url=urllib.urlopen(baseUrl+self.REQUEST['QUERY_STRING'])
             dom=xml.dom.minidom.parse(url)              dom=xml.dom.minidom.parse(url)
Line 520  class zogiLib(Folder): Line 529  class zogiLib(Folder):
                 paramH[param.getAttribute('name')]=param.getAttribute('value')                  paramH[param.getAttribute('name')]=param.getAttribute('value')
             return paramH              return paramH
         except:          except:
             return null              return {}
   
   
     def createHeadJS(self):      def createHeadJS(self):
Line 554  class zogiLib(Folder): Line 563  class zogiLib(Folder):
         # if not explicitly defined take normal request          # if not explicitly defined take normal request
         if not requestString:          if not requestString:
             requestString = self.getAllDLParams()              requestString = self.getAllDLParams()
         url = self.digilibBaseUrl+requestString          url = self.dlServerURL+'/servlet/Scaler?'+requestString
         # construct bottom and side insets          # construct bottom and side insets
         b_par = ""          b_par = ""
         s_par = ""          s_par = ""
Line 614  class zogiLib(Folder): Line 623  class zogiLib(Folder):
   
     def dl_lib_js(self):      def dl_lib_js(self):
         """javascript"""          """javascript"""
         return sendFile(self, 'js/dl_lib.js', 'text/plain')          return sendFile(self, 'js/dllib.js', 'text/plain')
   
     def js_lib_js(self):      def js_lib_js(self):
         """javascript"""          """javascript"""
         return sendFile(self, 'js/js_lib.js', 'text/plain')          return sendFile(self, 'js/baselib.js', 'text/plain')
   
     def optionwindow(self):      def optionwindow(self):
         """showoptions"""          """showoptions"""
     self.checkQuery()      self.checkQuery()
           if self.REQUEST.has_key('frametarget'):
               self.dlTarget = self.REQUEST['frametarget']
           print "current dltarget: ", self.dlTarget
     bt = self.REQUEST.SESSION['browserType']      bt = self.REQUEST.SESSION['browserType']
         if bt['staticHTML']:          if bt['staticHTML']:
             pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/optionwindow_static.zpt')).__of__(self)              pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/optionwindow_static.zpt')).__of__(self)
Line 827  class zogiLib(Folder): Line 839  class zogiLib(Folder):
             self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'?'+params)              self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'?'+params)
   
     def getMetaFileName(self):      def getMetaFileName(self):
         urlbase=re.sub('/servlet/Scaler','/dlContext-xml.jsp',self.digilibBaseUrl)          url=self.dlServerURL+'/dlContext-xml.jsp?'+self.getAllDLParams()
                   return urlbase
       
         return urlbase+self.getAllDLParams()  
   
   
       def getToolbarPageURL(self):
           """returns a toolbar-enabled page URL"""
           url=self.dlServerURL+'/digimage.jsp?'+self.getAllDLParams()
           return url
           
     def getDLTarget(self):      def getDLTarget(self):
         """returns dlTarget"""          """returns dlTarget"""
Line 1081  class zogiLib(Folder): Line 1094  class zogiLib(Folder):
         pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/changeZogiLibForm.zpt')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/changeZogiLibForm.zpt')).__of__(self)
         return pt()          return pt()
           
     def changeZogiLib(self,title,digilibBaseUrl, localFileBase, version, basePath, dlTarget, RESPONSE=None):      def changeZogiLib(self,title,dlServerURL, localFileBase, version, basePath, dlTarget, RESPONSE=None):
         """change it"""          """change it"""
         self.title=title          self.title=title
         self.digilibBaseUrl=digilibBaseUrl          self.dlServerURL=dlServerURL
         self.localFileBase=localFileBase          self.localFileBase=localFileBase
         self.basePath = basePath          self.basePath = basePath
         self.layout=version          self.layout=version
Line 1097  class zogiLib(Folder): Line 1110  class zogiLib(Folder):
             RESPONSE.redirect('manage_main')              RESPONSE.redirect('manage_main')
   
                       
   
       ##
       ## odd stuff
       ##
   
       def repairZogilib(self, obj=None):
           """change stuff that broke on upgrading"""
   
           msg = ""
   
           if not obj:
               obj = self.getPhysicalRoot()
   
           print "starting in ", obj
           
           entries=obj.ZopeFind(obj,obj_metatypes=['zogiLib'],search_sub=1)
   
           for entry in entries:
               print "  found ", entry
               if hasattr(entry[1], 'digilibBaseUrl'):
                   msg += "  fixing "+entry[0]+"/n"
                   entry[1].dlServerURL = re.sub('/servlet/Scaler?','',entry[1].digilibBaseUrl)
                   del entry[1].digilibBaseUrl
                   
           return msg+"\n\nfixed all zogilib instances in: "+obj.title
   
             
 def manage_addZogiLibForm(self):  def manage_addZogiLibForm(self):
     """interface for adding zogilib"""      """interface for adding zogilib"""
     pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiLibForm')).__of__(self)      pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiLibForm')).__of__(self)
     return pt()      return pt()
   
 def manage_addZogiLib(self,id,title,digilibBaseUrl, localFileBase,version="book",basePath="",dlTarget="digilib",RESPONSE=None):  def manage_addZogiLib(self,id,title,dlServerURL, localFileBase,version="book",basePath="",dlTarget="digilib",RESPONSE=None):
     """add dgilib"""      """add dgilib"""
     newObj=zogiLib(id,title,digilibBaseUrl, localFileBase, version, basePath, dlTarget)      newObj=zogiLib(id,title,dlServerURL, localFileBase, version, basePath, dlTarget)
     self.Destination()._setObject(id,newObj)      self.Destination()._setObject(id,newObj)
     if RESPONSE is not None:      if RESPONSE is not None:
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
Line 1146  def manage_addZogiLibPageTemplate(self, Line 1186  def manage_addZogiLibPageTemplate(self,
     u = "%s/%s" % (u, urllib.quote(id))      u = "%s/%s" % (u, urllib.quote(id))
     REQUEST.RESPONSE.redirect(u+'/manage_main')      REQUEST.RESPONSE.redirect(u+'/manage_main')
     return ''      return ''
   

Removed from v.1.32  
changed lines
  Added in v.1.35


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>