Diff for /MPIWGWeb/MPIWGProjects.py between versions 1.47.2.20 and 1.47.2.30

version 1.47.2.20, 2005/08/30 17:07:53 version 1.47.2.30, 2005/10/14 15:21:22
Line 2 Line 2
 for organizing and maintaining the different project pages  for organizing and maintaining the different project pages
   
 """  """
   #TODO: mechanismus fur links to personen ueberarbeiten, da jetzt alle e_mails als members auftauchen unabhaengig vom status publish_the_data
   #TODO: was passiert wenn aenderungen von jochen im filemaker nicht mit den aenderungen im sql uebereinstimmen
   
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile  from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from Products.PageTemplates.PageTemplate import PageTemplate  from Products.PageTemplates.PageTemplate import PageTemplate
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate  from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
 from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder  from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder
 from Products.ZCatalog.CatalogPathAwareness import CatalogAware  from Products.ZCatalog.CatalogPathAwareness import CatalogAware
   from OFS.Image import Image
 from Globals import package_home  from Globals import package_home
 import urllib  import urllib
 import MPIWGStaff  import MPIWGStaff
Line 15  import re Line 19  import re
 import os  import os
 from types import *  from types import *
 import zLOG  import zLOG
 import xmlhelper # Methoden zur Verwaltung der projekt xmls  import xmlhelper # Methoden zur Verwaltung der projekt xml
 from OFS.SimpleItem import SimpleItem  from OFS.SimpleItem import SimpleItem
 from OFS.Folder import Folder  from OFS.Folder import Folder
 from Products.ZSQLMethods.SQL import SQLConnectionIDs  from Products.ZSQLMethods.SQL import SQLConnectionIDs
   from AccessControl import ClassSecurityInfo
 from bibliography import *  from bibliography import *
 import time  import time
   import xml.dom.minidom
   import sys
   from Ft.Xml.XPath import Evaluate
   from Ft.Xml.XPath.Context import Context
   from Ft.Xml.Domlette import NonvalidatingReader,PrettyPrint, Print
   from Ft.Xml import EMPTY_NAMESPACE
   
 definedFields=['WEB_title','xdata_01','xdata_02','xdata_03','xdata_04','xdata_05','xdata_06','xdata_07','xdata_08','xdata_09','xdata_10','xdata_11','xdata_12','xdata_13','WEB_project_header','WEB_project_description','WEB_related_pub']  definedFields=['WEB_title','xdata_01','xdata_02','xdata_03','xdata_04','xdata_05','xdata_06','xdata_07','xdata_08','xdata_09','xdata_10','xdata_11','xdata_12','xdata_13','WEB_project_header','WEB_project_description','WEB_related_pub']
   
 checkFields = ['xdata_01']  checkFields = ['xdata_01']
   
   
   def getTextFromNode(nodename):
       nodelist=nodename.childNodes
       rc = ""
       for node in nodelist:
           if node.nodeType == node.TEXT_NODE:
              rc = rc + node.data
       return rc
   
 def sortF(x,y):  def sortF(x,y):
     try:      try:
Line 268  class MPIWGRoot(ZSQLExtendFolder): Line 285  class MPIWGRoot(ZSQLExtendFolder):
             txt="""<h2>Auf dieser Seite finden Sie die Projekte mit Stand vom %s</h2>"""%str(date)              txt="""<h2>Auf dieser Seite finden Sie die Projekte mit Stand vom %s</h2>"""%str(date)
         return ""          return ""
           
           
       def createOrUpdateId_raw(self):
           """create sequence to create ids for bibliography"""
           debug=None
           #suche groesste existierende id
           founds=self.ZSQLQuery("select id from bibliography")
           
           if founds:
               ids=[int(x.id[1:]) for x in founds]
               maximum=max(ids)
               
               id_raw=self.ZSQLQuery("select nextval('id_raw_test')",debug=debug)
               
               if id_raw:
                   self.ZSQLQuery("drop sequence id_raw_test",debug=debug)
               
               self.ZSQLQuery("create sequence id_raw_test start %i"%(maximum+1),debug=debug)
           
       
     def queryLink(self,link):      def queryLink(self,link):
         """append querystring to the link"""          """append querystring to the link"""
         return "%s?%s"%(link,self.REQUEST.get('QUERY_STRING',''))          return "%s?%s"%(link,self.REQUEST.get('QUERY_STRING',''))
Line 500  class MPIWGRoot(ZSQLExtendFolder): Line 536  class MPIWGRoot(ZSQLExtendFolder):
                             list[urllib.quote(personNormal)]=(personNormal,[project[1]])                              list[urllib.quote(personNormal)]=(personNormal,[project[1]])
   
             except:              except:
                 zLOG.LOG("MPIWG Web (harvestHistoricalPerson)",zLOG.ERROR,"cannot annalyize: %s"%repr(project))                  zLOG.LOG("MPIWG Web (harvestHistoricalPerson)",zLOG.ERROR,"cannot analyize: %s"%repr(project))
   
                                   
         return list          return list
Line 664  class MPIWGRoot(ZSQLExtendFolder): Line 700  class MPIWGRoot(ZSQLExtendFolder):
           
                   
     manage_options = Folder.manage_options+(      manage_options = Folder.manage_options+(
         {'label':'Update Personal Homepages','action':'updateHomepages'},          {'label':'Update personal homepages','action':'updateHomepages'},
           {'label':'Reindex catalogs','action':'reindexCatalogs'},
         {'label':'Main config','action':'changeMPIWGRootForm'},          {'label':'Main config','action':'changeMPIWGRootForm'},
         {'label':'Edit Historical Persons','action':'editHistoricalPersonsForm'},          #{'label':'Edit Historical Persons','action':'editHistoricalPersonsForm'},
         {'label':'Store Historical Persons','action':'storeHistoricalPersons'},          #{'label':'Store Historical Persons','action':'storeHistoricalPersons'},
         )          )
           
     def importNamesForm(self):      def importNamesForm(self):
Line 699  class MPIWGRoot(ZSQLExtendFolder): Line 736  class MPIWGRoot(ZSQLExtendFolder):
         if RESPONSE is not None:          if RESPONSE is not None:
             RESPONSE.redirect('manage_main')              RESPONSE.redirect('manage_main')
   
     def updateHomepages(self,RESPONSE):      def updatePublicationDB(self,personId=None):
         """lege members an"""          """updates the publication db, i.e. copy year into the main table"""
           
           if personId:
               founds = self.ZSQLInlineSearch(_table="publications",id_main=personId)
           else:
               founds = self.ZSQLInlineSearch(_table="publications")
               
           for found in founds:
                           
               if found.id_institutsbibliographie and (not found.id_institutsbibliographie =="") and (not found.id_institutsbibliographie =="0"):
                   
                   entries = self.ZSQLInlineSearch(_table="institutsbiblio",id=found.id_institutsbibliographie)
                   for entry in entries:
                       self.ZSQLChange(_table='publications',_identify='oid=%s' % found.oid,year=entry.year,referencetype=entry.reference_type)
                       
               if found.id_gen_bib and (not found.id_gen_bib ==""):
                   entries = self.ZSQLInlineSearch(_table="bibliography",id=found.id_gen_bib)
                   for entry in entries:
                       self.ZSQLChange(_table='publications',_identify='oid=%s' % found.oid,year=entry.year,referencetype=entry.reference_type)
                       
           return True        
           
       def updateHomepages(self,RESPONSE=None):
           """ update"""
           RESPONSE.write("<html><body>\n")
           url="http://itgroup.mpiwg-berlin.mpg.de:8050/FMPro?-db=personal-www&-format=-dso_xml&-lay=sql_export&-max=10000&-findall"
           dom = NonvalidatingReader.parseUri(url)
           #fh=urllib.urlopen(url)
           #dom=xml.dom.minidom.parse(fh)
           RESPONSE.write("got_xml_File\n")
           
           
           memberFolder=getattr(self,'members')
           members=memberFolder.ZopeFind(memberFolder,obj_metatypes=["MPIWGStaff"])
           
           memberList=[x[0] for x in members]
           #print dom
           #ctx=Context(dom,processorNss={EMPTY_NAMESPACE:'http://www.filemaker.com/fmpdsoresult'})
           # Evaluate(u".//dn:ROW",contextNode=dom,explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})
           #print dom.xpath(u'.//dn:ROW',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})
           for row in dom.xpath(u'.//dn:ROW',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'}):
           
               username=getTextFromNode(row.xpath('./dn:username',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               id=getTextFromNode(row.xpath('./dn:ID',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               name=getTextFromNode(row.xpath('./dn:Name',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               vorname=getTextFromNode(row.xpath('./dn:Vorname',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               title=getTextFromNode(row.xpath('./dn:Title',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               e_mail=getTextFromNode(row.xpath('./dn:e_mail',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               e_mail_p=getTextFromNode(row.xpath('./dn:e_mail_p',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               date_from=getTextFromNode(row.xpath('./dn:Date_from',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               date_to=getTextFromNode(row.xpath('./dn:Date_to',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               abteilung=getTextFromNode(row.xpath('./dn:Abteilung',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               heimat_inst=getTextFromNode(row.xpath('./dn:heimat_inst',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               funded_by=getTextFromNode(row.xpath('./dn:funded_by',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               e_mail2=getTextFromNode(row.xpath('./dn:e_mail2',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
               publish_the_data=getTextFromNode(row.xpath('./dn:publish_the_data',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
              
               #cwNode=row.xpath('./dn:current_work.current',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0]
               cw=row.xpath('./dn:current_work/dn:DATA',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})
               if cw:
                   txt=getTextFromNode(cw[0])
               else:
                   txt=""
              
               #cwNode=row.xpath('.//dn:current_work.publish',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0]
               cw=row.xpath('./dn:current_work/dn:DATA',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})
   
               if cw:
                   txt_p=getTextFromNode(cw[0])
               else:
                   txt_p=""
                
               project=getattr(self,'members')
               
               if not (username in memberList):#neuer eintrag
                   
                   try:
                       newObj=MPIWGStaff.MPIWGStaff(str(username),name.encode('utf-8'),vorname.encode('utf-8'))
                       memberFolder._setObject(str(username),newObj)
                       RESPONSE.write("<p>new:%s</p>\n"%username.encode('utf-8'))
                       obj=getattr(memberFolder,username)
                       ret=obj.createNewDBEntry(publish_the_data,id,name,
                                             vorname,username,title,e_mail,
                                             e_mail_p,date_from,date_to,
                                             abteilung,heimat_inst,funded_by,
                                             e_mail2,txt,txt_p)
                       RESPONSE.write("""<p>%s</p>"""%ret[1].encode('utf-8'))
                   except:
                       RESPONSE.write("<p>ERROR:%s %s %s</p>\n"%(username.encode('utf-8'),name.encode('utf-8'),vorname.encode('utf-8')))
                       RESPONSE.write("<p>      : %s %s"%sys.exc_info()[:2])
               else:
                   RESPONSE.write("<p>update:%s</p>\n"%username.encode('utf-8'))
                   
                   xquery=".//dn:ROW[dn:username='%s']"%username
                   results=dom.xpath(xquery,explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})
                   if len(results)>1:
                       RESPONSE.write("<p>WARNING (update): username %s not unique</p>\n"%username.encode('utf-8'))
                       xquery=".//dn:ROW[dn:publish_the_data='yes' and dn:username='%s']"%username
                       rd=dom.xpath(xquery,explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'}) 
                       if len(rd)>1:#mehrere published
                           RESPONSE.write("<p>ERROR (update): username %s not unique and more then one date  set to be published</p>\n"%username.encode('utf-8'))
   #                    elif len(rd)==1:#nur einer published, kein published dann mache nichts
   #                        publish_the_data=getTextFromNode(rd[0].xpath('./dn:publish_the_data',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
   #                        date_from=getTextFromNode(rd[0].xpath('./dn:Date_from',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
   #                        date_to=getTextFromNode(rd[0].xpath('./dn:Date_to',explicitNss={'dn':'http://www.filemaker.com/fmpdsoresult'})[0])
   #              
   
                   obj=getattr(memberFolder,username)
                   
                   obj.updateDBEntry(DBid=id,publish_the_data=publish_the_data,
                                      date_from=date_from,
                                      date_to=date_to)
   
           self.reindexCatalogs(RESPONSE)
       
           self.updatePublicationDB() 
              
           if RESPONSE:
               RESPONSE.redirect('manage_main')
   
           
              
           return True
        
       def reindexCatalogs(self,RESPONSE=None):
           """reindex members and project catalog"""
                   
           
           try:
               self.MembersCatalog.manage_catalogReindex(self.REQUEST,RESPONSE,self.REQUEST['URL1'])
               self.ProjectCatalog.manage_catalogReindex(self.REQUEST,RESPONSE,self.REQUEST['URL1'])
           except:
               zLOG.LOG("MPIWG Root (updatehomepage)",zLOG.WARNING," %s %s"%sys.exc_info()[:2])
               
           
       
              
           if RESPONSE:
               RESPONSE.redirect('manage_main')
   
           
           
       def updateHomepages_old(self,RESPONSE):
           """lege members an, alte version vollstaendige kopie aller fm-dateien per fm.jar"""
         self.upDateSQL('personalwww.xml')          self.upDateSQL('personalwww.xml')
         founds=self.ZSQLInlineSearch(_table='personal_www',publish_the_data='yes')          founds=self.ZSQLInlineSearch(_table='personal_www',publish_the_data='yes')
         project=getattr(self,'members')          project=getattr(self,'members')
Line 717  class MPIWGRoot(ZSQLExtendFolder): Line 896  class MPIWGRoot(ZSQLExtendFolder):
                     RESPONSE.write("<p>old:%s (%s,%s)</p>\n"%(found.username,found.name,found.vorname))                      RESPONSE.write("<p>old:%s (%s,%s)</p>\n"%(found.username,found.name,found.vorname))
   
   
   
         #delete non existing          #delete non existing
   
   
Line 732  class MPIWGRoot(ZSQLExtendFolder): Line 912  class MPIWGRoot(ZSQLExtendFolder):
             pass              pass
         self.ProjectCatalog.manage_catalogReindex(self.REQUEST,RESPONSE,self.REQUEST['URL1'])          self.ProjectCatalog.manage_catalogReindex(self.REQUEST,RESPONSE,self.REQUEST['URL1'])
           
           self.updatePublicationDB() 
                                           
         if RESPONSE is not None:          if RESPONSE is not None:
             RESPONSE.redirect('manage_main')              RESPONSE.redirect('manage_main')
Line 746  class MPIWGRoot(ZSQLExtendFolder): Line 927  class MPIWGRoot(ZSQLExtendFolder):
         #    ret.append(x.title.decode('utf-8'))          #    ret.append(x.title.decode('utf-8'))
   
         for x in self.ZopeFind(self.members,obj_metatypes=['MPIWGStaff']):          for x in self.ZopeFind(self.members,obj_metatypes=['MPIWGStaff']):
               if x[1].isPublished():
                                ret.append(x[1].title.decode('utf-8'))                                 ret.append(x[1].title.decode('utf-8'))
                           
         ret.sort()          ret.sort()
Line 973  class MPIWGRoot(ZSQLExtendFolder): Line 1155  class MPIWGRoot(ZSQLExtendFolder):
                     except:                      except:
                         proj=None                          proj=None
   
                 if proj:                  if proj and (proj[0].getObject().isPublished()):
             if person =="Otto Sibum" : person="H. Otto Sibum"              if person =="Otto Sibum" : person="H. Otto Sibum"
             if person =="Norton Wise" : person="M. Norton Wise"              if person =="Norton Wise" : person="M. Norton Wise"
                     #ret.append("<a href=%s >%s</a>"%(proj[0].absolute_url,person.encode('utf-8')))                      #ret.append("<a href=%s >%s</a>"%(proj[0].absolute_url,person.encode('utf-8')))
Line 1119  class MPIWGRoot(ZSQLExtendFolder): Line 1301  class MPIWGRoot(ZSQLExtendFolder):
         return (fieldname in checkFields)          return (fieldname in checkFields)
   
   
       
       
           
 def manage_addMPIWGRootForm(self):  def manage_addMPIWGRootForm(self):
     """form for adding the root"""      """form for adding the root"""
     pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMPIWGRootForm.zpt')).__of__(self)      pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMPIWGRootForm.zpt')).__of__(self)
Line 1137  def manage_addMPIWGRoot(self,id,title,co Line 1316  def manage_addMPIWGRoot(self,id,title,co
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
                   
   
   class MPIWGProject_publication(SimpleItem):
       """publications object fuer project"""
   
       meta_type="MPIWGProject_publication"
   
       def editPublication(self,text=None,RESPONSE=None):
           """edit a publication"""
   
           if (not text):
               pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_publicationForm.zpt')).__of__(self)
               return pt()
   
          
           self.text=text[0:]
   
           if RESPONSE:
               RESPONSE.redirect("../managePublications")
               
   class MPIWGProject_image(Image):
       """Images for Projects"""
   
       meta_type="MPIWGProject_image"
   
       def showImage(self,imageUrl=None):
           """show Images at an extra page"""
           self.getContent('WEB_project_description',filter='yes') #get the content and store image infos into session
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','projectImageView.zpt')).__of__(self)
           return pt()
       
       def editImage(self,file=None,caption=None,RESPONSE=None):
           """edit the Image"""
           if (not file) and (not caption):
               pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_imageForm.zpt')).__of__(self)
               return pt()
   
           if file and (not file.filename.lstrip().rstrip()==""):
               self.manage_upload(file)
   
           if caption:
               self.caption=caption[0:]
   
           if RESPONSE:
               RESPONSE.redirect("../manageImages")
   
 class MPIWGProject(CatalogAware,Folder):  class MPIWGProject(CatalogAware,Folder):
     """Class for Projects"""      """Class for Projects"""
   
   
       security=ClassSecurityInfo()
     meta_type='MPIWGProject'      meta_type='MPIWGProject'
     default_catalog='ProjectCatalog'      default_catalog='ProjectCatalog'
           
       def sortedByPlace(self,metatype):
           """find metatype and sort by place"""
           def sort(x,y):
               return cmp(getattr(x[1],'place',0),getattr(y[1],'place',0))
   
           founds=self.ZopeFind(self,obj_metatypes=[metatype]);
           
           founds.sort(sort)
           
           return founds
       
   
       def copyPublicationsToList(self,RESPONSE=None):
           """copy publications in to list"""
   
           publicationTxt=self.getContent('WEB_related_pub')
   
           pubSplits=publicationTxt.split("<p>")
   
           for pubSplit in pubSplits:
               pubSplit=pubSplit.replace("</p>","")
               self.addPublication(pubSplit)
   
           if RESPONSE:
               RESPONSE.redirect('managePublications')
           
       
       def copyImageToMargin(self,RESPONSE=None):
           """copy inline images to marginal images"""
           self.getContent('WEB_project_description',filter='yes')
   
           filename=self.imageURL.split("/")[-1]
           #lege neues images object an, mit leerem bild
   
           if self.ZopeFind(self,obj_ids=[filename]):
               #existiert das bild schon, dann neueun filenamen
               filename="project_image_"+filename
               
           self.addImage(None,self.imagecap,filename=filename)
           #hole die bilddaten aus der url
           data=urllib.urlopen(self.absolute_url()+"/"+self.imageURL).read()
   
           obj=getattr(self,filename)
           obj.update_data(data)
           
           if RESPONSE:
               RESPONSE.redirect('manageImages')
               
       def manageImages(self,imageName=None,op=None):
           """managage images"""
   
   
           if imageName and op:
               if op=='up':
                   images=self.getImages()
                   for image in images:
                       if image[0]==imageName:
                           nr=images.index(image)
                           if not nr==0:
                               images[nr-1][1].place+=1
                               images[nr][1].place-=1
                           pass
               elif op=='down':
                   images=self.getImages()
                   for image in images:
                       if image[0]==imageName:
                           nr=images.index(image)
                           if not (nr==len(images)-1):
                               images[nr+1][1].place-=1
                               images[nr][1].place+=1
                           pass
   
   
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_manageImagesForm.zpt')).__of__(self)
           return pt()
   
       def managePublications(self,pubName=None,op=None):
           """managage images"""
   
   
           if pubName and op:
               if op=='up':
                   publications=self.getPublications()
                   for publication in publications:
                       if publication[0]==pubName:
                           nr=publications.index(publication)
                           if not nr==0:
                               publications[nr-1][1].place+=1
                               publications[nr][1].place-=1
                           pass
               elif op=='down':
                   publications=self.getPublications()
                   for publication in publications:
                       if publication[0]==pubName:
                           nr=publications.index(publication)
                           if not (nr==len(publications)-1):
                               publications[nr+1][1].place-=1
                               publications[nr][1].place+=1
                           pass
   
   
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_managePublicationsForm.zpt')).__of__(self)
           return pt()
   
       def getPublications(self):
           """get all Publications"""
           def sort_images(x,y):
               return cmp(getattr(x[1],'place',0),getattr(y[1],'place',0))
   
           publications=self.ZopeFind(self,obj_metatypes=['MPIWGProject_publication'])
           
           publications.sort(sort_images)
           return publications
   
       def addPublication(self,text,RESPONSE=None):
           """add an MPIWG_Publication"""
   
           name="publication_"+str(self.getLastPublicationNumber()+1)
           
           newPublication=MPIWGProject_publication(name)
   
           self._setObject(name,newPublication)
           obj=getattr(self,name)
           obj.text=text[0:]
           obj.enabled=True;
           obj.place=self.getLastPublicationNumber()+1
           obj.id=name
           
           if RESPONSE is not None:
               RESPONSE.redirect('managePublications')
   
    
       def getLastPublicationNumber(self):
           publications=self.getPublications()
           
           if not publications:
               return 0
           else:
               return getattr(publications[-1][1],'place',0)
           
       def deletePublication(self,id,RESPONSE=None):
           """delete Publication id"""
           self.manage_delObjects([id])
           if RESPONSE:
               RESPONSE.redirect('managePublications')
   
       def getImages(self):
           """get all Images"""
           def sort_images(x,y):
               return cmp(getattr(x[1],'place',0),getattr(y[1],'place',0))
   
           images=self.ZopeFind(self,obj_metatypes=['MPIWGProject_image'])
           
           images.sort(sort_images)
           return images
   
       def getLastImageNumber(self):
           images=self.getImages()
           
           if not images:
               return 0
           else:
               return getattr(images[-1][1],'place',0)
           
       def deleteImage(self,id,RESPONSE=None):
           """delete Image id"""
           self.manage_delObjects([id])
           if RESPONSE:
               RESPONSE.redirect('manageImages')
   
       def addImage(self,fileHd,caption,RESPONSE=None,filename=None):
           """add an MPIWG_Project_image"""
   
           if not filename:
               filename=fileHd.filename
   
           if not fileHd:
               fileHd=file(os.path.join(package_home(globals()),'blank.gif'))
               
           newImage=MPIWGProject_image(filename,filename,fileHd)
   
           self._setObject(filename,newImage)
           obj=getattr(self,filename)
           obj.caption=caption[0:]
           obj.enabled=True;
           obj.place=self.getLastImageNumber()+1
           
           if RESPONSE is not None:
               RESPONSE.redirect('manageImages')
   
     def PrincipiaSearchSource(self):      def PrincipiaSearchSource(self):
         """Return cataloguable key for ourselves."""          """Return cataloguable key for ourselves."""
         return str(self)          return str(self)
Line 1473  class MPIWGProject(CatalogAware,Folder): Line 1888  class MPIWGProject(CatalogAware,Folder):
     def saveEditedContent(self,kupu=None,preview=None):      def saveEditedContent(self,kupu=None,preview=None):
         """save Edited content"""          """save Edited content"""
   
           if preview:
         kupu=preview          kupu=preview
         #find content of body tags          #find content of body tags
         start=kupu.find("<body>")          start=kupu.find("<body>")
Line 1480  class MPIWGProject(CatalogAware,Folder): Line 1896  class MPIWGProject(CatalogAware,Folder):
         newcontent= kupu[start+6:end]          newcontent= kupu[start+6:end]
   
         if preview:          if preview:
               
             return self.preview(newcontent)              return self.preview(newcontent)
   
           self.copyObjectToArchive()
         self.WEB_project_description=newcontent[0:]          self.WEB_project_description=newcontent[0:]
   
         self.REQUEST.RESPONSE.redirect("./edit")          self.REQUEST.RESPONSE.redirect("./index.html")
                   
         return True          return True
           
     def edit(self):      security.declareProtected('View managment screens','edit')
       def edit(self,western=None):
         """Edit pages"""          """Edit pages"""
           if western:
               self.REQUEST.RESPONSE.setCookie("MP_debug_code","western",path="/")
   
               
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGProjectNeu.zpt')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGProjectNeu.zpt')).__of__(self)
         return pt()          return pt()
   
Line 1511  class MPIWGProject(CatalogAware,Folder): Line 1934  class MPIWGProject(CatalogAware,Folder):
   
     def getWebProject_description(self):      def getWebProject_description(self):
         """get description"""          """get description"""
           debug= self.REQUEST.cookies.get("MP_debug_code",None)
           
           if debug and debug=="western":
               return """
               <html>
               <head>
               <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
               </head>
               <body>%s
               </html></body>
               """%self.WEB_project_description[0]
           
           return """
               <html>
               <head>
               <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
               </head>
               <body>%s
               </html></body>
               """%self.getContent('WEB_project_description')
                   
         if type(self.WEB_project_description) is ListType:  
             return "<html><body>Hello"+self.WEB_project_description[0]+"</body></html>"  
         else:  
             return self.WEB_project_description  
                   
                   
     def editMPIWGProjectForm(self):      def editMPIWGProjectForm(self):
Line 1523  class MPIWGProject(CatalogAware,Folder): Line 1962  class MPIWGProject(CatalogAware,Folder):
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGProject.zpt')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGProject.zpt')).__of__(self)
         return pt()          return pt()
   
       
     def editMPIWGProject(self,RESPONSE=None,fromEdit=None):      def editMPIWGProject(self,RESPONSE=None,fromEdit=None):
         """edit the project and archive the old version"""          """edit the project and archive the old version"""
                   
Line 1542  class MPIWGProject(CatalogAware,Folder): Line 1982  class MPIWGProject(CatalogAware,Folder):
                 RESPONSE.redirect('manage_main')                  RESPONSE.redirect('manage_main')
   
   
   
       security.declareProtected('View managment screens','editMPIWGDisciplinesThemesEditor')
     def editMPIWGDisciplinesThemesEditor(self):      def editMPIWGDisciplinesThemesEditor(self):
         """edit from edit"""          """edit from edit"""
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGDisciplinesThemesNeu.zpt')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGDisciplinesThemesNeu.zpt')).__of__(self)
Line 1595  class MPIWGProject(CatalogAware,Folder): Line 2037  class MPIWGProject(CatalogAware,Folder):
                 return 1                  return 1
         return 0          return 0
   
       security.declareProtected('View management screens','editMPIWGBasisEditor')
     def editMPIWGBasisEditor(self):      def editMPIWGBasisEditor(self):
         """editform"""          """editform"""
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGBasisNeu.zpt')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGBasisNeu.zpt')).__of__(self)

Removed from v.1.47.2.20  
changed lines
  Added in v.1.47.2.30


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