--- MPIWGWeb/MPIWGProjects.py 2005/09/14 20:45:56 1.47.2.22 +++ MPIWGWeb/MPIWGProjects.py 2005/10/11 13:14:01 1.47.2.27 @@ -16,7 +16,7 @@ import re import os from types import * 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.Folder import Folder from Products.ZSQLMethods.SQL import SQLConnectionIDs @@ -95,7 +95,7 @@ class MPIWGLink(SimpleItem): splitted=self.link.lstrip().split("/") obj=self for x in splitted: - if not x=="": + if not x=="": obj=getattr(obj,x) return obj @@ -188,7 +188,7 @@ class MPIWGTemplate(ZopePageTemplate): return "aktiv" else: return "" - + def manage_addMPIWGTemplateForm(self): """Form for adding""" pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/AddMPIWGTemplate.zpt')).__of__(self) @@ -274,20 +274,20 @@ class MPIWGRoot(ZSQLExtendFolder): return "%s?%s"%(link,self.REQUEST.get('QUERY_STRING','')) def getKategory(self,url): - """kategorie""" - splitted=url.split("/") - return splitted[4] + """kategorie""" + splitted=url.split("/") + return splitted[4] def generateUrlProject(self,url,project=None): """erzeuge aus absoluter url, relative des Projektes""" - if project: + if project: splitted=url.split("/") length=len(splitted) short=splitted[length-2:length] base=self.REQUEST['URL3']+"/"+"/".join(short) - else: + else: findPart=url.find("/projects/") base=self.REQUEST['URL1']+"/"+url[findPart:] @@ -352,16 +352,16 @@ class MPIWGRoot(ZSQLExtendFolder): xmlPath=os.path.join(package_home(globals()), "updateSQL/%s"%fileName) zLOG.LOG("MPIWG Web",zLOG.INFO,"java -classpath %s -Djava.awt.headless=true Convert %s"%(fmJarPath,xmlPath)) ret=os.popen("java -classpath %s -Djava.awt.headless=true Convert %s"%(fmJarPath,xmlPath),"r").read() - zLOG.LOG("MPIWG Web",zLOG.INFO,"result convert: %s"%ret) + zLOG.LOG("MPIWG Web",zLOG.INFO,"result convert: %s"%ret) return 1 def patchProjects(self,RESPONSE): """patch""" projects=self.ZopeFind(self.projects,obj_metatypes=['MPIWGProject']) for project in projects: - tmp=project[1].WEB_project_description[0].replace("/CD/projects/","")[0:] - setattr(project[1],'WEB_project_description',[tmp[0:]]) - RESPONSE.write("
%s
\n"%project[0]) + tmp=project[1].WEB_project_description[0].replace("/CD/projects/","")[0:] + setattr(project[1],'WEB_project_description',[tmp[0:]]) + RESPONSE.write("%s
\n"%project[0]) def replaceNotEmpty(self,format,field): """replace not empty""" @@ -545,9 +545,9 @@ class MPIWGRoot(ZSQLExtendFolder): def getProjectsByFieldContent(self,fieldName,fieldContentsEntry, date=None): """gib alle Projekte aus mit Value von field mit fieldName enthält ein Element der Liste fieldContents""" def sort(x,y): - return cmp(x.WEB_title[0],y.WEB_title[0]) + return cmp(x.WEB_title[0],y.WEB_title[0]) - if type(fieldContentsEntry) is StringType: + if type(fieldContentsEntry) is StringType: fieldContentsTmp=[fieldContentsEntry] else: fieldContentsTmp=fieldContentsEntry @@ -557,7 +557,7 @@ class MPIWGRoot(ZSQLExtendFolder): fieldContents.append(" AND ".join(x.split())) projects=self.ProjectCatalog({fieldName:string.join(fieldContents,' AND')}) #print projects - #ret=[x for x in projects] + #ret=[x for x in projects] ret=[] for x in projects: obj=x.getObject() @@ -566,7 +566,7 @@ class MPIWGRoot(ZSQLExtendFolder): #if not (x in ret): ret.append(x) - ret.sort(sort) + ret.sort(sort) return ret def changeMPIWGRootForm(self): @@ -700,9 +700,32 @@ class MPIWGRoot(ZSQLExtendFolder): if RESPONSE is not None: RESPONSE.redirect('manage_main') + def updatePublicationDB(self,personId=None): + """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: + print found + if found.id_institutsbibliographie and (not found.id_institutsbibliographie ==""): + 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): """lege members an""" - self.upDateSQL('personalwww.xml') founds=self.ZSQLInlineSearch(_table='personal_www',publish_the_data='yes') project=getattr(self,'members') @@ -717,6 +740,7 @@ class MPIWGRoot(ZSQLExtendFolder): except: RESPONSE.write("old:%s (%s,%s)
\n"%(found.username,found.name,found.vorname)) + #delete non existing @@ -733,7 +757,8 @@ class MPIWGRoot(ZSQLExtendFolder): pass self.ProjectCatalog.manage_catalogReindex(self.REQUEST,RESPONSE,self.REQUEST['URL1']) - + self.updatePublicationDB() + if RESPONSE is not None: RESPONSE.redirect('manage_main') @@ -785,7 +810,7 @@ class MPIWGRoot(ZSQLExtendFolder): #title=project[0].WEB_title title=[project[0].getContent('WEB_title')] #print title - if idNr[0]!="x": + if idNr[0]!="x": returnList.append((depth,nr,title,project[0])) return returnList @@ -821,8 +846,8 @@ class MPIWGRoot(ZSQLExtendFolder): department=int(element[3].getContent('xdata_05'))-1 ret+="""\n""" - if department==4: #hack - department=3 + if department==4: #hack + department=3 ret+="""""") if len(splitted)>1: tmp=splitted[1].split("
") - #return repr(splitted[1]) + #return repr(splitted[1]) try: - self.imageURL=tmp[0].split("\"")[1].encode('utf-8') - except: - self.imageURL=tmp[0].split("src=")[1].split(" ")[0].encode('utf-8') - + self.imageURL=tmp[0].split("\"")[1].encode('utf-8') + except: + self.imageURL=tmp[0].split("src=")[1].split(" ")[0].encode('utf-8') + split2="".join(tmp[1:]) text3=splitted[0]+split2 @@ -1665,7 +1690,7 @@ class MPIWGProject(CatalogAware,Folder): splitted=text3.split("""""") if len(splitted)>1: tmp=splitted[1].split("
") - self.imagecap=tmp[0].encode('utf-8') + self.imagecap=tmp[0].encode('utf-8') split4="".join(tmp[1:]) @@ -1710,24 +1735,31 @@ class MPIWGProject(CatalogAware,Folder): def saveEditedContent(self,kupu=None,preview=None): """save Edited content""" - kupu=preview + if preview: + kupu=preview #find content of body tags start=kupu.find("") end=kupu.find("") newcontent= kupu[start+6:end] if preview: + return self.preview(newcontent) + self.copyObjectToArchive() self.WEB_project_description=newcontent[0:] - self.REQUEST.RESPONSE.redirect("./edit") + self.REQUEST.RESPONSE.redirect("./index.html") return True security.declareProtected('View managment screens','edit') - def edit(self): + def edit(self,western=None): """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) return pt() @@ -1749,11 +1781,27 @@ class MPIWGProject(CatalogAware,Folder): def getWebProject_description(self): """get description""" + debug= self.REQUEST.cookies.get("MP_debug_code",None) + + if debug and debug=="western": + return """ + + + + + %s + + """%self.WEB_project_description[0] + + return """ + + + + + %s + + """%self.getContent('WEB_project_description') - if type(self.WEB_project_description) is ListType: - return ""+self.WEB_project_description[0]+"" - else: - return self.WEB_project_description def editMPIWGProjectForm(self):