Diff for /ECHO_content/ECHO_collection.py between versions 1.163 and 1.170

version 1.163, 2004/08/17 15:22:14 version 1.170, 2004/09/27 19:55:08
Line 270  def getText(nodelist): Line 270  def getText(nodelist):
            rc = rc + node.data             rc = rc + node.data
     return rc      return rc
   
   def getTextFromNode(nodename):
       nodelist=nodename.childNodes
       rc = ""
       for node in nodelist:
           if node.nodeType == node.TEXT_NODE:
              rc = rc + node.data
       return rc
   
 def sendFile(self, filename, type):  def sendFile(self, filename, type):
     """sends an object or a local file (in the product) as response"""      """sends an object or a local file (in the product) as response"""
Line 513  class ECHO_copyright(Folder): Line 520  class ECHO_copyright(Folder):
         {'label':'Main Config','action':'ECHO_copyright_configForm'},          {'label':'Main Config','action':'ECHO_copyright_configForm'},
         )          )
   
   
     def ECHO_copyright_configForm(self):      def ECHO_copyright_configForm(self):
         """change form"""          """change form"""
         pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_copyright').__of__(self)          pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_copyright').__of__(self)
Line 666  class ECHO_fullText(ZopePageTemplate): Line 674  class ECHO_fullText(ZopePageTemplate):
         # 3 handler functions          # 3 handler functions
         def start_element(name, attrs):          def start_element(name, attrs):
             global retLex              global retLex
             print name              
             retLex+=createTag(name,attrs)              retLex+=createTag(name,attrs)
         def end_element(name):          def end_element(name):
             global retLex              global retLex
Line 689  class ECHO_fullText(ZopePageTemplate): Line 697  class ECHO_fullText(ZopePageTemplate):
         p.CharacterDataHandler = char_data          p.CharacterDataHandler = char_data
                   
         p.Parse(lemmatized.encode('utf-8'),1)          p.Parse(lemmatized.encode('utf-8'),1)
         print repr(lemmatized.encode('utf-8'))          #print repr(lemmatized.encode('utf-8'))
           
         return retLex          return retLex
           
Line 797  class ECHO_resource(Folder,Persistent): Line 805  class ECHO_resource(Folder,Persistent):
         """showrdf"""          """showrdf"""
             self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')              self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
         ret="""<?xml version="1.0" encoding="utf-8"?>\n<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  xmlns:ECHONAVIGATION="http://www.echo.eu/rdf#">\n"""          ret="""<?xml version="1.0" encoding="utf-8"?>\n<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  xmlns:ECHONAVIGATION="http://www.echo.eu/rdf#">\n"""
         ret+=self.getRDF(urn="echo:collectionroot")+"\n"          ret+=self.getRDF(urn="echo:colllectionroot")+"\n"
   
         ret+="""</RDF:RDF>"""          ret+="""</RDF:RDF>"""
             return ret               return ret 
Line 1019  class ECHO_resource(Folder,Persistent): Line 1027  class ECHO_resource(Folder,Persistent):
         path=re.sub('http://foxridge.rz-berlin.mpg.de:8080','',path) # falls foxridge als server          path=re.sub('http://foxridge.rz-berlin.mpg.de:8080','',path) # falls foxridge als server
             path=re.sub('http://content.mpiwg-berlin.mpg.de','',path) # falls content als server              path=re.sub('http://content.mpiwg-berlin.mpg.de','',path) # falls content als server
         path=re.sub('http://foxridge.rz-berlin.mpg.de','',path) # falls foxridge als server          path=re.sub('http://foxridge.rz-berlin.mpg.de','',path) # falls foxridge als server
           path=re.sub('http://vision.rz-berlin.mpg.de','',path) # falls vision als server
         path=re.sub('/index.meta','',path)           path=re.sub('/index.meta','',path) 
   
   
Line 1082  class ECHO_resource(Folder,Persistent): Line 1091  class ECHO_resource(Folder,Persistent):
         path=re.sub('http://foxridge.rz-berlin.mpg.de:8080','',path) # falls foxridge als server          path=re.sub('http://foxridge.rz-berlin.mpg.de:8080','',path) # falls foxridge als server
         path=re.sub('http://foxridge.rz-berlin.mpg.de','',path) # falls foxridge als server          path=re.sub('http://foxridge.rz-berlin.mpg.de','',path) # falls foxridge als server
         path=re.sub('http://content.mpiwg-berlin.mpg.de','',path) # falls content als server          path=re.sub('http://content.mpiwg-berlin.mpg.de','',path) # falls content als server
   
           path=re.sub('http://vision.rz-berlin.mpg.de','',path) # falls vision als server
   
         return ECHO_helpers.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines()          return ECHO_helpers.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines()
   
   
         if RESPONSE is not None:          if RESPONSE is not None:
             RESPONSE.redirect('manage_main')              RESPONSE.redirect('manage_main')
   
Line 2529  class ECHO_collection(Folder, Persistent Line 2542  class ECHO_collection(Folder, Persistent
         else:          else:
             return "#dddddd"              return "#dddddd"
                   
     def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",viewClassification=None,location=None):      def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",viewClassification=None,location=None,isAlwaysClickable=None):
         """Aenderung der Properties"""          """Aenderung der Properties"""
   
         self.secondaryLink=secondaryLink          self.secondaryLink=secondaryLink
Line 2538  class ECHO_collection(Folder, Persistent Line 2551  class ECHO_collection(Folder, Persistent
     self.bgcolour=bgcolour      self.bgcolour=bgcolour
         self.viewClassification=viewClassification          self.viewClassification=viewClassification
         self.location=location          self.location=location
       self.isAlwaysClickable=isAlwaysClickable
           
         if coords:          if coords:
             coordsnew=[ string.split(x,",") for x in coords]              coordsnew=[ string.split(x,",") for x in coords]
Line 2557  class ECHO_collection(Folder, Persistent Line 2571  class ECHO_collection(Folder, Persistent
         if RESPONSE is not None:          if RESPONSE is not None:
             RESPONSE.redirect('manage_main')              RESPONSE.redirect('manage_main')
                           
       def setAlwaysClickable(self,flag="yes"):
           """set clickable"""
           if flag=="yes":
               self.isAlwaysClickable="yes"
           else:
               self.isAlwaysClickable=None
   
           return flag
   
     def showOverview(self):      def showOverview(self):
         """overview"""          """overview"""
Line 2929  def manage_addECHO_userFolderForm(self): Line 2951  def manage_addECHO_userFolderForm(self):
     """add a user folder form"""      """add a user folder form"""
     return manage_addECHO_userFolder(self)      return manage_addECHO_userFolder(self)
   
   
   
   def createNode(self,descrs,node):
       name=descrs[node]['name']
       type=descrs[node]['type']
       urn=node
       #print "    will create",node.encode('utf-8')
       id=re.sub('[^a-zA-Z0-9]','',name).encode('ascii','ignore')
       #print "id",id
       #print type
       #self.REQUEST.RESPONSE.write("<p>%s<p>\n"%id)
       if type=="CDLI_group":
           
           try:
               manage_addECHO_collection(self,id,name,name,"","","","","")
           
           except:
               self.REQUEST.RESPONSE.write("<p>Error%s</p>\n"%id)
               
           self.REQUEST.RESPONSE.write("<p>Creates:%s</p>\n"%getattr(self,id).absolute_url())
           
           return type,getattr(self,id),urn
   
       if type=="CDLI_item":
           try:
               manage_addECHO_resource(self,id,name,name,"","",urn,"","")
           except:
               self.REQUEST.RESPONSE.write("<p>Error%s</p>\n"%id)
           self.REQUEST.RESPONSE.write("<p>Creates:%s</p>\n"%getattr(self,id).absolute_url())
           
           
       return "XX"
   
   
 class ECHO_root(Folder,Persistent,Implicit):  class ECHO_root(Folder,Persistent,Implicit):
     """ECHO Root Folder"""      """ECHO Root Folder"""
   
Line 2936  class ECHO_root(Folder,Persistent,Implic Line 2992  class ECHO_root(Folder,Persistent,Implic
           
     meta_type="ECHO_root"      meta_type="ECHO_root"
           
       ###CDLI adds -> have to be removed
       def getTablet(self,item):
           #print "getTablet"
       try:
           read=urllib.urlopen("http://enlil.museum.upenn.edu/cgi-bin/cdlget.plx?item=%s&project=ncdl"%item).read()
                   read=re.sub("\[search\]","search",read)
           return read[read.find("<body>")+6:read.rfind("</body>")]
       except:
           return "<h1>Sorry no connection to the data server enlil.museum.upenn.edu</h1>"
       #return "http://enlil.museum.upenn.edu/cgi-bin/cdlget.plx?item=%s&project=ncdl"
       ###END CDLI add
   
       
       def generateFromRDFForm(self):
           """change form"""
           pt=PageTemplateFile('Products/ECHO_content/zpt/generateFromRDFForm').__of__(self)
           pt.content_type="text/html"
           return pt()
   
       def generateFromRDF(self,file,startNode="/Cuneiform Corpus"):
   
           """generate from RDF"""
   
           global seqs
           seqs={}
           global descrs
           descrs={}
           global key
           key=""
           global value
           value=""
   
           def getEdges(seqs,urn):
               """edges"""
               ret=[]
               return seqs[urn]
   
           def createSubs(self,seqs,descrs,urn,level=0):
               """create subs"""
               for edge in getEdges(seqs,urn):
                   cn=createNode(self,descrs,edge)
                   if cn[0]=="CDLI_group":
                       createSubs(cn[1],seqs,descrs,cn[2],level+1)
               return
   
           def start_element(name,attrs):
   
               global seqs
               global descrs
               global key
               global value
               seq=""
               if name=="RDF:Seq":
                   key=attrs.get('RDF:about')
                   try: # teste ob liste
                       x=seqs[key][0]
                   except:
   
                       seqs[key]=[]
   
               
               elif name=="RDF:Description":
                   key=attrs.get('RDF:about')
                   
   
               elif name=="RDF:li":
                   name=attrs.get('RDF:resource')
                   seqs[key].append(name)
   
               elif name=="ECHONAVIGATION:type":
                   value="type"
   
               elif name=="ECHONAVIGATION:name":
                   value="name"
               elif name=="ECHONAVIGATION:linkClickable":
                   value="linkClickable"
                   
           def end_element(name):
                   """nothing"""
                   key=""
                   value=""
   
           def char_data(data):
               """nothing"""
   
               data=re.sub("\n","",data)
               try:
                   if descrs[key].has_key(value):
                       descrs[key][value]+=data
                   else:
                       descrs[key][value]=data
               except:
   
                   descrs[key]={}
                   descrs[key][value]=data
                   
           p = xml.parsers.expat.ParserCreate()
           
           p.StartElementHandler = start_element
           p.EndElementHandler = end_element
           p.CharacterDataHandler = char_data
           
           
           p.ParseFile(file)
           self.REQUEST.RESPONSE.write("<html><body><h1>Start</h1>")
           createSubs(self,seqs,descrs,startNode)
           self.REQUEST.RESPONSE.write("<h1>done</h1></body></html>")
           #print "done"
   
           
           return "done"
       
           
   
           
     def changeWeightsInCollection(self):      def changeWeightsInCollection(self):
         """change all lables of a collection"""          """change all lables of a collection"""
         ret=""          ret=""
Line 2962  class ECHO_root(Folder,Persistent,Implic Line 3133  class ECHO_root(Folder,Persistent,Implic
         {'label':'Main Config','action':'ECHO_copyright_configForm'},          {'label':'Main Config','action':'ECHO_copyright_configForm'},
         {'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'},          {'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'},
         {'label':'Change Weights','action':'changeWeights'},          {'label':'Change Weights','action':'changeWeights'},
           {'label':'Generate from RDF','action':'generateFromRDFForm'},
   
         )          )
   
           
Line 3228  class ECHO_root(Folder,Persistent,Implic Line 3401  class ECHO_root(Folder,Persistent,Implic
                                   
         return "changed all contenttypes in: "+self.title          return "changed all contenttypes in: "+self.title
   
       def deleteCache(self,obj=None,RESPONSE=None):
           """setze alle collections auf cache = CacheManager"""
   
       
           if not obj:
               obj = self
               
           entries=obj.ZopeFind(obj,search_sub=1)
   
           for entry in entries:
           if hasattr(entry[1],'_v_hash'):
               entry[1]._v_hash=None
               
   
   
           
           return "changed all CM in: "+self.title
   
   
       
     def ECHO_newViewerLink(self,obj=None):      def ECHO_newViewerLink(self,obj=None):
         """change links (:86 faellt weg)"""          """change links (:86 faellt weg)"""
   
Line 3294  class ECHO_root(Folder,Persistent,Implic Line 3487  class ECHO_root(Folder,Persistent,Implic
             for link in links:              for link in links:
                 link.tagName="a"                  link.tagName="a"
                 ref=link.getAttribute("ref")                  ref=link.getAttribute("ref")
           pn=link.getAttribute("page")
               
                 if self.checkRef(ref):                  if self.checkRef(ref):
               if pn:
                   link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref+"&p="+pn)
               else:
                     link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref)                      link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref)
   
   
             newxml=dom.toxml('utf-8')              newxml=dom.toxml('utf-8')
               
         retStr=regexpTXT.search(newxml)          retStr=regexpTXT.search(newxml)
Line 3308  class ECHO_root(Folder,Persistent,Implic Line 3507  class ECHO_root(Folder,Persistent,Implic
   
     def xml2html(self,str,quote="yes"):      def xml2html(self,str,quote="yes"):
         """link2html fuer VLP muss hier noch raus"""          """link2html fuer VLP muss hier noch raus"""
     print str      #print str
   
         if str:          if str:
             if quote=="yes2":              if quote=="yes2":
                 str=re.sub("\&","&amp;",str)                  str=re.sub("\&","&amp;",str)
             dom=xml.dom.minidom.parseString(str)              dom=xml.dom.minidom.parseString(str)
             links=dom.getElementsByTagName("link")              links=dom.getElementsByTagName("link")
                           
   
             for link in links:              for link in links:
                 link.tagName="a"                  link.tagName="a"
                 ref=link.getAttribute("ref")                  ref=link.getAttribute("ref")
           pn=link.getAttribute("page")
   
                 if self.checkRef(ref):                  if self.checkRef(ref):
               if pn:
                   link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref+"&p="+pn)
               else:
                     link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref)                      link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref)
   
             str= dom.toxml()              str= dom.toxml()
Line 3331  class ECHO_root(Folder,Persistent,Implic Line 3535  class ECHO_root(Folder,Persistent,Implic
         return ""          return ""
   
     def checkRef(self,ref):      def checkRef(self,ref):
         dbs={'vl_literature':'AND CD LIKE \'%lise%\'','vl_technology':'','vl_people':''}          dbs={'vl_literature':'AND CD LIKE \'%lise%\'','vl_technology':'','vl_people':'','vl_sites':''}
         res=None          res=None
         for db in dbs.keys():          for db in dbs.keys():
   
Line 3471  class ECHO_root(Folder,Persistent,Implic Line 3675  class ECHO_root(Folder,Persistent,Implic
   
     def getMetaDatasXML(self,viewerType=None,filter=None):      def getMetaDatasXML(self,viewerType=None,filter=None):
         """gebe all ressourcen aus"""          """gebe all ressourcen aus"""
           # check if the request's host part was OK
           http_host = self.REQUEST['HTTP_HOST']
           host_port = self.REQUEST['SERVER_PORT']
           fix_host = None
           if http_host and http_host.rfind(host_port) == -1:
               print "HTTP_HOST needs fixing!"
               fix_host = http_host + ":" + host_port
   
         ret="""<?xml version="1.0" ?>          ret="""<?xml version="1.0" ?>
                  <index>"""                   <index>"""
         for resource in self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1):          for resource in self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1):
   
             echo_url=resource[1].absolute_url()              echo_url=resource[1].absolute_url()
               if fix_host:
                   #print "replacing ", http_host, " by ", fix_host
                   echo_url = string.replace(echo_url, http_host, fix_host, 1)
                           
             if hasattr(resource[1],'link'):              if hasattr(resource[1],'link'):
                 meta_url=echo_url+"/getMetaDataXML"                  meta_url=echo_url+"/getMetaDataXML"
Line 3494  class ECHO_root(Folder,Persistent,Implic Line 3709  class ECHO_root(Folder,Persistent,Implic
                                   
         ret +="""\n</index>"""          ret +="""\n</index>"""
                   
           
         self.REQUEST.RESPONSE.setHeader("Content-Type", "text/xml")          self.REQUEST.RESPONSE.setHeader("Content-Type", "text/xml")
         self.REQUEST.RESPONSE.write(ret)          self.REQUEST.RESPONSE.write(ret)
   

Removed from v.1.163  
changed lines
  Added in v.1.170


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