--- MPIWGWeb/MPIWGProjects.py 2005/04/25 16:58:02 1.46 +++ MPIWGWeb/MPIWGProjects.py 2005/12/22 21:10:14 1.47.2.45 @@ -2,11 +2,16 @@ 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 +#TODO: in einzelnen projecte steht als pfad auf die bilder noch wwwneu statt www + from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplate import PageTemplate from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder from Products.ZCatalog.CatalogPathAwareness import CatalogAware +from OFS.Image import Image from Globals import package_home import urllib import MPIWGStaff @@ -15,19 +20,32 @@ 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 - +from AccessControl import ClassSecurityInfo from bibliography import * 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'] 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): try: @@ -61,11 +79,111 @@ def sortI(x,y): except: return cmp(x[1],y[1]) +class MPIWGLink(SimpleItem): + """create a symbolic link to another page""" + + meta_type="MPIWGLink" + + def isActiveItem(self): + """teste ob ausgewaehlt""" + #url1 beim link anstelle von url1, da link jeweils index_html als url hat. + if self.absolute_url()==self.REQUEST['URL1']: + return "aktiv" + else: + return "" + + def __init__(self,id,link,title='',weight=''): + """init mpiwglink""" + self.id=id + self.link=link + self.title=title + self.weight=weight + + def getObj(self): + """bekomme original""" + ## objpath=self.link.replace("/",".") +## if objpath[0]!=".": +## objpath="."+objpath + +## print objpath +## return eval("self"+objpath) + + + splitted=self.link.lstrip().split("/") + obj=self + for x in splitted: + if not x=="": + obj=getattr(obj,x) + + return obj + + def getWeight(self): + if self.linkWeight and linkWeight!="": + return self.linkWeight + else: + return self.getObj().weight + + manage_options=SimpleItem.manage_options+( + {'label':'main config','action':'changeLinkForm'}, + ) + + + def changeLinkForm(self): + """change MPIWG link""" + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGLinkChange.zpt')).__of__(self) + return pt() + + def changeLink(self,link,title,weight,RESPONSE=None): + """change links""" + self.link=link + self.title=title + self.weight=weight + + if RESPONSE is not None: + RESPONSE.redirect('manage') + + def index_html(self): + """index""" + + return self.getObj().pt_render(extra_context={'here':self}) + + +def manage_addMPIWGLinkForm(self): + """Form for adding link""" + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/AddMPIWGLink.zpt')).__of__(self) + return pt() + +def manage_addMPIWGLink(self,id,link,title,weight,RESPONSE=None): + """add link""" + newObj=MPIWGLink(id,link,title,weight) + + self._setObject(id,newObj) + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + class MPIWGTemplate(ZopePageTemplate): """Create a layout Template for different purposes""" meta_type="MPIWGTemplate" + manage_options=ZopePageTemplate.manage_options+( + {'label':'Change Weight','action':'changeWeightForm'}, + ) + + def changeWeightForm(self): + """change weight form""" + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGTemplateChangeWeight.zpt')).__of__(self) + return pt() + + def changeWeight(self,weight,RESPONSE=None): + """change weight""" + self.weight=weight + if RESPONSE is not None: + RESPONSE.redirect('manage') + + def __init__(self, id, text=None, content_type=None,MPIWGType=None): self.id = str(id) @@ -81,7 +199,13 @@ class MPIWGTemplate(ZopePageTemplate): """change form""" - + def isActiveItem(self): + """teste ob ausgewaehlt""" + if self.absolute_url()==self.REQUEST['URL']: + return "aktiv" + else: + return "" + def manage_addMPIWGTemplateForm(self): """Form for adding""" pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/AddMPIWGTemplate.zpt')).__of__(self) @@ -90,7 +214,7 @@ def manage_addMPIWGTemplateForm(self): from urllib import quote -def manage_addMPIWGTemplate(self, MPIWGType,id, title=None,REQUEST=None): +def manage_addMPIWGTemplate(self, MPIWGType,id, title=None,weight=0,REQUEST=None): "Add a Page Template with optional file content." if type(MPIWGType)==StringType: MPIWGTypes=[MPIWGType] @@ -125,7 +249,9 @@ def manage_addMPIWGTemplate(self, MPIWGT except AttributeError: u = REQUEST['URL1'] - + ob = getattr(self, id) + ob.weight=weight + REQUEST.RESPONSE.redirect(u+'/manage_main') return '' @@ -136,7 +262,7 @@ class MPIWGRoot(ZSQLExtendFolder): fieldLabels={'WEB_title':'WEB_Title','xdata_01':'Responsible Scientists','xdata_02':'Department', 'xdata_03':'Historical Persons','xdata_04':'Time period', 'xdata_05':'Sorting number','xdata_06':'Keywords','xdata_07':'Short title', - 'xdata_08':'Other involved scholars' ,'xdata_09':'Part of','xdata_10':'Covered by', + 'xdata_08':'Other involved scholars' ,'xdata_09':'Disciplines','xdata_10':'Themes', 'xdata_11':'Object Digitallibrary','xdata_12':'Cooperation partners', 'xdata_13':'Funding institutions','WEB_project_header':'WEB_project_header', 'WEB_project_description':'WEB_project_description','WEB_related_pub':'WEB_related_pub'} @@ -144,22 +270,134 @@ class MPIWGRoot(ZSQLExtendFolder): folders=['MPIWGProject','Folder','ECHO_Navigation'] meta_type='MPIWGRoot' + def versionHeaderEN(self): + """version header text""" + + date= self.REQUEST.get('date',None) + if date: + txt="""

This pages shows the project which existed at %s

"""%str(date) + return txt + return "" + + def versionHeaderDE(self): + """version header text""" + date= self.REQUEST.get('date',None) + if date: + txt="""

Auf dieser Seite finden Sie die Projekte mit Stand vom %s

"""%str(date) + 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')",debug=debug) + + if id_raw: + self.ZSQLQuery("drop sequence id_raw",debug=debug) + + self.ZSQLQuery("create sequence id_raw start %i"%(maximum+1),debug=debug) + + + def queryLink(self,link): + """append querystring to the link""" + return "%s?%s"%(link,self.REQUEST.get('QUERY_STRING','')) + + def getKategory(self,url): + """kategorie""" + splitted=url.split("/") + return splitted[4] + + def generateUrlProject(self,url,project=None): + """erzeuge aus absoluter url, relative des Projektes""" + if project: + splitted=url.split("/") + length=len(splitted) + short=splitted[length-2:length] + + base=self.REQUEST['URL3']+"/"+"/".join(short) + + else: + findPart=url.find("/projects/") + base=self.REQUEST['URL1']+"/"+url[findPart:] + + + return base + + def isNewCapital(self,text=None,reset=None): + if reset: + self.REQUEST['capital']="A" + return True + else: + if len(text)>0 and not (text[0]==self.REQUEST['capital']): + self.REQUEST['capital']=text[0] + return True + else: + return False + + def subNav(self,obj): + """return subnav elemente""" + def sortWeight(x,y): + x1=int(getattr(x[1],'weight','0')) + y1=int(getattr(y[1],'weight','0')) + return cmp(x1,y1) + #if obj.meta_type in ['MPIWGTemplate','MPIWGLink']: + # id=obj.aq_parent.getId() + #else: + + #id=obj.getId() + + + #suche die zweite ebene + if not obj.aq_parent.getId() in ['de','en']: + obj=obj.aq_parent + + while not self.ZopeFind(self,obj_ids=[obj.getId()]): + obj=obj.aq_parent + + if hasattr(self,obj.getId()): + + subs=self.ZopeFind(getattr(self,obj.getId()),obj_metatypes=['MPIWGTemplate','MPIWGLink']) + subret=[] + + for x in subs: + if not(x[1].title==""): + subret.append(x) + subret.sort(sortWeight) + return subret + else: + return None + + def isActive(self,name): + """teste ob subnavigation aktiv""" + for part in self.REQUEST['URL'].split("/"): + if part==name: + return True + return False + + def upDateSQL(self,fileName): """updates SQL databases using fm.jar""" fmJarPath=os.path.join(package_home(globals()), 'updateSQL/fm.jar') 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""" @@ -299,7 +537,7 @@ class MPIWGRoot(ZSQLExtendFolder): list[urllib.quote(personNormal)]=(personNormal,[project[1]]) 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 @@ -340,16 +578,32 @@ class MPIWGRoot(ZSQLExtendFolder): pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editHistoricalPersonsForm')).__of__(self) return pt() - def getProjectsByFieldContent(self,fieldName,fieldContentsEntry): + 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]) + if type(fieldContentsEntry) is StringType: - fieldContents=[fieldContentsEntry] + fieldContentsTmp=[fieldContentsEntry] else: - fieldContents=fieldContentsEntry - - projects=self.ProjectCatalog({fieldName:string.join(fieldContents,' OR')}) + fieldContentsTmp=fieldContentsEntry + + fieldContents=[] + for x in fieldContentsTmp: + fieldContents.append(" AND ".join(x.split())) + projects=self.ProjectCatalog({fieldName:string.join(fieldContents,' AND')}) #print projects - return projects + #ret=[x for x in projects] + ret=[] + for x in projects: + obj=x.getObject() + obj=obj.getActualVersion(date) + if obj and (not getattr(obj,'invisible',None)): + #if not (x in ret): + ret.append(x) + + ret.sort(sort) + return ret def changeMPIWGRootForm(self): """edit""" @@ -368,29 +622,32 @@ class MPIWGRoot(ZSQLExtendFolder): def getDisciplineList(self): """get disciplines as list""" - return self.disciplineList.split("\n") + list= self.disciplineList.split("\n") + return [x.rstrip().lstrip() for x in list] def getThemeList(self): """get themes as list""" - return self.themesList.split("\n") + list= self.themesList.split("\n") + return [x.rstrip().lstrip() for x in list] def test(self): """test""" return self.getProjectsByFieldContent('xdata_09',['biology'])[0].absolute_url - def getContexts(self,childs=None,parents=None,depth=None): + def getContexts(self,childs=None,parents=None,depth=None,date=None): """childs alle childs, alle parents""" ret=[] + if parents: splitted=parents.split(".") parentId=string.join(splitted[0:len(splitted)-1],".") - for project in self.getProjectFields('xdata_05',sort='int'): + for project in self.getProjectFields('xdata_05',sort='int',date=date): if project[1]==parentId: ret.append(project) if childs: - for project in self.getProjectFields('xdata_05',sort='int'): + for project in self.getProjectFields('xdata_05',sort='int',date=date): searchStr=childs+"(\..*)" if re.match(searchStr,project[1]): @@ -403,7 +660,7 @@ class MPIWGRoot(ZSQLExtendFolder): ret.append(project) return ret - def getProjectFields(self,fieldName,folder=None,sort=None): + def getProjectFields(self,fieldName,date=None,folder=None,sort=None): """getListofFieldNames""" ret=[] @@ -412,8 +669,8 @@ class MPIWGRoot(ZSQLExtendFolder): for object in objects: obj=object[1] - - if not getattr(obj,'invisible',None): + obj=obj.getActualVersion(date) + if obj and (not getattr(obj,'invisible',None)): if fieldName=="WEB_title_or_short": if len(obj.getContent('xdata_07'))<3: # hack weil z.Z. manchmal noch ein Trennzeichen ; oder , im Feld statt leer @@ -436,7 +693,7 @@ class MPIWGRoot(ZSQLExtendFolder): def showNewProjects(self): projects=[] for objs in self.getProjectFields('WEB_title_or_short'): # Get all Projets - if objs[0].xdata_05[0] == "": + if objs[0].xdata_05 and (objs[0].xdata_05[0] == ""): projects.append(objs) @@ -444,10 +701,11 @@ class MPIWGRoot(ZSQLExtendFolder): 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':'Edit Historical Persons','action':'editHistoricalPersonsForm'}, - {'label':'Store Historical Persons','action':'storeHistoricalPersons'}, + #{'label':'Edit Historical Persons','action':'editHistoricalPersonsForm'}, + #{'label':'Store Historical Persons','action':'storeHistoricalPersons'}, ) def importNamesForm(self): @@ -479,9 +737,165 @@ class MPIWGRoot(ZSQLExtendFolder): if RESPONSE is not None: RESPONSE.redirect('manage_main') - def updateHomepages(self,RESPONSE): - """lege members an""" + 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: + + 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.setHeader('Content-type', 'text/html') + RESPONSE.write("\n") + url="http://itgroup.mpiwg-berlin.mpg.de:8050/FMPro?-db=personal-www&-format=-dso_xml&-lay=sql_export&-max=20000&-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]) + position=getTextFromNode(row.xpath('./dn:Position',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]) + stay_at_mpiwg=getTextFromNode(row.xpath('./dn:stay_at_mpiwg',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("

new:%s

\n"%username.encode('utf-8')) + obj=getattr(memberFolder,username) + ret=obj.createNewDBEntry(publish_the_data,id,name, + vorname,username,title,position,e_mail, + e_mail_p,date_from,date_to, + abteilung,heimat_inst,funded_by, + e_mail2,txt,txt_p) + RESPONSE.write("""

%s

"""%ret[1].encode('utf-8')) + except: + RESPONSE.write("

ERROR:%s %s %s

\n"%(username.encode('utf-8'),name.encode('utf-8'),vorname.encode('utf-8'))) + RESPONSE.write("

: %s %s"%sys.exc_info()[:2]) + else: + RESPONSE.write("

update:%s

\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("

WARNING (update): username %s not unique

\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("

ERROR (update): username %s not unique and more then one date set to be published

\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) + + done= obj.updateDBEntry(DBid=id,publish_the_data=publish_the_data, + date_from=date_from, + date_to=date_to,stay_at_mpiwg=stay_at_mpiwg,position=position) + if not done and (publish_the_data=='yes'): + + ret=obj.createNewDBEntry(publish_the_data,id,name, + vorname,username,title,position,e_mail, + e_mail_p,date_from,date_to, + abteilung,heimat_inst,funded_by, + e_mail2,txt,txt_p) + if not ret[0]: + + RESPONSE.write("

Error: %s

\n"%repr(ret[1])) + else: + RESPONSE.write("

New: %s

\n"%repr(ret[1])) + + #TODO: reindexCatlogs and updatePublications wieder einbaue + #self.reindexCatalogs(RESPONSE) + + #self.updatePublicationDB() + + self.ZSQLResetConnection() + RESPONSE.write("

Done

") + + 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') founds=self.ZSQLInlineSearch(_table='personal_www',publish_the_data='yes') project=getattr(self,'members') @@ -496,6 +910,7 @@ class MPIWGRoot(ZSQLExtendFolder): except: RESPONSE.write("

old:%s (%s,%s)

\n"%(found.username,found.name,found.vorname)) + #delete non existing @@ -512,7 +927,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') @@ -526,6 +942,7 @@ class MPIWGRoot(ZSQLExtendFolder): # ret.append(x.title.decode('utf-8')) for x in self.ZopeFind(self.members,obj_metatypes=['MPIWGStaff']): + if x[1].isPublished(): ret.append(x[1].title.decode('utf-8')) ret.sort() @@ -550,10 +967,11 @@ class MPIWGRoot(ZSQLExtendFolder): return entry - def getTree(self): + def getTree(self,date=None): """generate Tree from project list""" + returnList=[] - for project in self.getProjectFields('xdata_05',sort="int"): # get Projects sorted by xdata_05 + for project in self.getProjectFields('xdata_05',sort="int",date=date): # get Projects sorted by xdata_05 for idNr in project[1].split(";"): # more than one number if not idNr=="": @@ -563,11 +981,65 @@ class MPIWGRoot(ZSQLExtendFolder): #title=project[0].WEB_title title=[project[0].getContent('WEB_title')] #print title - returnList.append((depth,nr,title,project[0])) + if idNr[0]!="x": + returnList.append((depth,nr,title,project[0])) return returnList + def formatElementsAsList(self,elements): + """formatiere tree als liste""" + + actualDepth=0 + ret="" + for element in elements: + if (element[0]>actualDepth): + #fuege soviele ul ein wie unterschied in tiefe + if element[0]==1: + ret+="""
\n
\n""" + if department==4: #hack + department=3 + + ret+="""
+
\n