--- MPIWGWeb/MPIWGProjects.py 2004/09/10 19:59:28 1.30 +++ MPIWGWeb/MPIWGProjects.py 2006/10/19 07:32:51 1.47.2.61 @@ -1,30 +1,76 @@ """This contains the class MPIWG Projects -for organizing and maintaining the different projectspages +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 import string import re +import os from types import * - -import xmlhelper # Methoden zur Verwaltung der projekt xmls +import zLOG +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 sortStopWordsF(self,xo,yo): + if not hasattr(self,'_v_stopWords'): + self._v_stopWords=self.stopwords_en.data.split("\n") + + x=str(xo[1]) + y=str(yo[1]) + + strx=x.split(" ") + stry=y.split(" ") + + for tmp in strx: + if tmp.lower() in self._v_stopWords: + del strx[strx.index(tmp)] + + for tmp in stry: + if tmp.lower() in self._v_stopWords: + del stry[stry.index(tmp)] + + return cmp(" ".join(strx)," ".join(stry)) + +def sortStopWords(self): + return lambda x,y : sortStopWordsF(self,x,y) + def sortF(x,y): try: return cmp(x[1],y[1]) @@ -32,7 +78,7 @@ def sortF(x,y): try: return cmp(str(x[1]),str(y[1])) except: - print "error",x[1],y[1] + return 0 def sortI(x,y): @@ -57,6 +103,182 @@ 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) + + + + self.ZBindings_edit(self._default_bindings) + if text is None: + self._default_content_fn = os.path.join(package_home(globals()), + 'zpt/MPIWG_%s_template_standard.zpt'%MPIWGType) + text = open(self._default_content_fn).read() + self.pt_edit(text, content_type) + + + """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) + return pt() + +from urllib import quote + + +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] + else: + MPIWGTypes=MPIWGType + + for singleType in MPIWGTypes: + + + if REQUEST is None: + self._setObject(id, MPIWGTemplate(id, text,EchoType=singleType)) + ob = getattr(self, id) + + if title: + ob.pt_setTitle(title) + return ob + else: + file = REQUEST.form.get('file') + headers = getattr(file, 'headers', None) + if headers is None or not file.filename: + zpt = MPIWGTemplate(id,MPIWGType=singleType) + else: + zpt = MPIWGTemplate(id, file, headers.get('content_type')) + + self._setObject(id, zpt) + ob = getattr(self, id) + if title: + ob.pt_setTitle(title) + + try: + u = self.DestinationURL() + except AttributeError: + u = REQUEST['URL1'] + + ob = getattr(self, id) + ob.weight=weight + + REQUEST.RESPONSE.redirect(u+'/manage_main') + return '' + class MPIWGRoot(ZSQLExtendFolder): """Stammordner für den Web-Server""" @@ -64,22 +286,209 @@ 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'} - folders=['MPIWGProject','Folder'] + folders=['MPIWGProject','Folder','ECHO_Navigation'] meta_type='MPIWGRoot' + def harvestProjects(self): + """harvest""" + folder="/tmp" + try: + os.mkdir("/tmp/harvest_MPIWG") + except: + pass + founds=self.ZopeFind(self.aq_parent.projects,obj_metatypes=['MPIWGProject'],search_sub=1) + for found in founds: + txt=found[1].harvest_page() + + if txt and (txt != ""): + name=found[0].replace("/","_") + fh=file("/tmp/harvest_MPIWG/"+name,"w") + fh.write(txt) + fh.close() + + def decode(self,str): + """decoder""" + if not str: + return "" + if type(str) is StringType: + try: + return str.decode('utf-8') + except: + return str.decode('latin-1') + else: + + return str + + def versionHeaderEN(self): + """version header text""" + + date= self.REQUEST.get('date',None) + if date: + txt="""
%s
\n"%project[0]) + def replaceNotEmpty(self,format,field): """replace not empty""" - if field and (not field==''): + if field and (not field.lstrip()==''): return format%field else: return "" + def isActual(self,project): + """checke if project is actual""" + actualTime=time.localtime() + obj= project.getObject() + + if getattr(obj,'archiveTime',actualTime)< actualTime: + return False + else: + return True + def redirectIndex_html(self,request): #return request['URL1']+'/index_html' @@ -152,6 +561,22 @@ class MPIWGRoot(ZSQLExtendFolder): self.id=id self.title=title + def removeStopWords(self,xo): + """remove stop words from xo""" + if not hasattr(self,'_v_stopWords'): + self._v_stopWords=self.stopwords_en.data.split("\n") + + x=str(xo) + + strx=x.split(" ") + + for tmp in strx: + + if tmp.lower() in self._v_stopWords: + del strx[strx.index(tmp)] + + return " ".join(strx) + def urlQuote(self,str): """quote""" return urllib.quote(str) @@ -200,7 +625,8 @@ class MPIWGRoot(ZSQLExtendFolder): list[urllib.quote(personNormal)]=(personNormal,[project[1]]) except: - print "ERROR",project + zLOG.LOG("MPIWG Web (harvestHistoricalPerson)",zLOG.ERROR,"cannot analyize: %s"%repr(project)) + return list @@ -231,34 +657,51 @@ class MPIWGRoot(ZSQLExtendFolder): def showHistoricalPersons(self): """show persons""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/showHistoricalPersons').__of__(self) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','showHistoricalPersons')).__of__(self) return pt() def editHistoricalPersonsForm(self): """edit historical persons for consistency""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/editHistoricalPersonsForm').__of__(self) + 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""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/changeMPIWGRootForm').__of__(self) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeMPIWGRootForm')).__of__(self) return pt() - def changeMPIWGRoot(self,title,disciplineList,themesList,RESPONSE=None): + def changeMPIWGRoot(self,title,disciplineList,themesList,connection_id,RESPONSE=None): """change""" self.title=title + self.connection_id=connection_id self.disciplineList=disciplineList self.themesList=themesList @@ -267,71 +710,75 @@ 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,onlyActive=True): """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]): - - if depth: - - if int(depth)>=len(project[1].split("."))-len(childs.split(".")): - + + if (onlyActive and project[0].isActiveProject()) or (not onlyActive): + if re.match(searchStr,project[1]): + + if depth: + + if int(depth)>=len(project[1].split("."))-len(childs.split(".")): + + ret.append(project) + else: ret.append(project) - else: - 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=[] - #print "FN",fieldName - if not folder: - folder=self - for object in folder.__dict__: - - obj=getattr(folder,object) - if hasattr(obj,'meta_type'): - #print obj.meta_type - if obj.meta_type=='MPIWGProject': - if fieldName=="WEB_title_or_short": - #print "HI!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - #print len(obj.getContent('xdata_07')) - if len(obj.getContent('xdata_07'))<3: # hack weil z.Z. manchmal noch ein Trennzeichen ; oder , im Feld statt leer - fieldNameTmp="WEB_title" - else: - fieldNameTmp="xdata_07" + + objects=self.ZopeFind(self.projects,obj_metatypes=['MPIWGProject'],search_sub=0) + + + for object in objects: + obj=object[1] + 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 + fieldNameTmp="WEB_title" else: - fieldNameTmp=fieldName - - ret.append((obj,obj.getContent(fieldNameTmp))) + fieldNameTmp="xdata_07" + else: + fieldNameTmp=fieldName - if obj.meta_type in self.folders: - - ret += self.getProjectFields(fieldName,obj) + ret.append((obj,obj.getContent(fieldNameTmp))) + if sort=="int": ret.sort(sortI) + elif sort=="stopWords": + + ret.sort(sortStopWords(self)) + else: ret.sort(sortF) @@ -340,7 +787,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) @@ -348,15 +795,16 @@ class MPIWGRoot(ZSQLExtendFolder): manage_options = Folder.manage_options+( - {'label':'Import Persons','action':'importNamesForm'}, + {'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): """Form""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/MPIWGNamesForm.zpt').__of__(self) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGNamesForm.zpt')).__of__(self) return pt() def importNames(self,fileupload,folderName,RESPONSE=None): @@ -377,29 +825,242 @@ class MPIWGRoot(ZSQLExtendFolder): project._setObject(splitted[0],newObj) #print "done:",splitted[0] except: - print "not done:",splitted[0] + zLOG.LOG("MPIWG Web (importNames)",zLOG.INFO,"cannot import: %s"%splitted[0]) + if RESPONSE is not None: RESPONSE.redirect('manage_main') - def getAllMembers(self): - """give list of all members""" - ret=[] + 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") + RESPONSE.write("Update Institutsbibliography\n") + ret=self.upDateSQL('personalwww.xml') + RESPONSE.write("done Insitutsbibliography:%s\n"%ret) + 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,stay_at_mpiwg) + 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]) +# - #for x in self.members.objectValues('MPIWGStaff'): - #print x.title - # ret.append(x.title.decode('utf-8')) + 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,abteilung=abteilung) + 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,stay_at_mpiwg) + if not ret[0]: - for x in self.ZopeFind(self.members,obj_metatypes=['MPIWGStaff']): - ret.append(x[1].title.decode('utf-8')) + 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("new:%s
\n"%found.username) + except: + RESPONSE.write("old:%s (%s,%s)
\n"%(found.username,found.name,found.vorname)) + + + + #delete non existing + + + foundUserNames=[x.username for x in founds] + for member in self.ZopeFind(self,obj_metatypes=["MPIWGStaff"],search_sub=1): + + if member[1].getId() not in foundUserNames: + member[1].aq_parent.manage_delObjects(ids=[member[1].getId()]) + RESPONSE.write("deleted:%s
\n"%member[1].getId()) + try: + self.MembersCatalog.manage_catalogReindex(self.REQUEST,RESPONSE,self.REQUEST['URL1']) + except: + pass + self.ProjectCatalog.manage_catalogReindex(self.REQUEST,RESPONSE,self.REQUEST['URL1']) + + self.updatePublicationDB() + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + +# def getAllMembers(self,reset=None): +# """give list of all members""" +# ret=[] +# +# +# if reset or (getattr(self,'_v_membersList',None) is None): +# for member in self.members._objects: +# if member['meta_type']=='MPIWGStaff': +# memberObj=getattr(self.members,member['id']) +# if memberObj.isPublished(): +# ret.append(memberObj.title.decode('utf-8')) +# +# ret.sort() +# self._v_membersList=ret[0:] +# print ret +# +# return self._v_membersList + + def getAllMembers(self): + #ret=[] + + results=self.MembersCatalog({'isPublished':True}) + + ret=[", ".join([proj.lastName, proj.firstName]).decode('utf-8') for proj in results] + + ret.sort() + return ret def printAllMembers(self): - """prin""" + """print""" members=self.getAllMembers() ret="" for x in members: @@ -415,10 +1076,12 @@ class MPIWGRoot(ZSQLExtendFolder): return entry - def getTree(self): + def getTree(self,dep=None,date=None,onlyActive=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=="": splittedId=idNr.split(".") @@ -427,26 +1090,91 @@ 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": # kompatibilitŠt mit alter Konvention, x vor der Nummer macht project inactive + project[0].setActiveFlag(False) + + if (not dep) or (idNr[0]==dep): #falls dep gesetzt ist nur dieses hinzufŸgen. + if onlyActive and project[0].isActiveProject(): #nur active projekte + returnList.append((depth,nr,title,project[0])) + elif not onlyActive: + returnList.append((depth,nr,title,project[0])) return returnList + def formatElementsAsList(self,elements,onlyOneDept=False): + """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+=""""""%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) + return """
"""%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) elif element[0]==3: - return """
"""%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) + return """"""%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) + def changePosition(self,treeId,select,RESPONSE=None): """Change Postion Entry""" @@ -488,10 +1216,21 @@ class MPIWGRoot(ZSQLExtendFolder): for idNr in form.keys(): - fields[int(idNr)][3].xdata_05=form[idNr] - - - + + splitted=idNr.split('_') + + if len(splitted)==1: # name des Feldes = idNr, dann Aendere id_nr + if not (fields[int(idNr)][3].xdata_05==form[idNr]): + fields[int(idNr)][3].xdata_05=form[idNr] + fields[int(idNr)][3].copyObjectToArchive() + + if form.has_key(idNr+'_active'): # active flag is set + + fields[int(splitted[0])][3].setActiveFlag(True) + else: + + fields[int(splitted[0])][3].setActiveFlag(False) + if RESPONSE is not None: RESPONSE.redirect('showTree') @@ -559,7 +1298,9 @@ class MPIWGRoot(ZSQLExtendFolder): except: proj=None - if proj: + if proj and (proj[0].getObject().isPublished()): + if person =="Otto Sibum" : person="H. Otto Sibum" + if person =="Norton Wise" : person="M. Norton Wise" #ret.append("%s"%(proj[0].absolute_url,person.encode('utf-8'))) ret.append("%s"%(proj[0].absolute_url+"/index.html",person)) else: @@ -567,17 +1308,19 @@ class MPIWGRoot(ZSQLExtendFolder): ret.append("%s"%person) return string.join(ret,";") - def getProjectsOfMembers(self): + def getProjectsOfMembers(self,date=None): """give tuple member /projects""" ret=[] members=self.getAllMembers() + #return str(members) for x in members: - ret+=self.getProjectsOfMember(name=x) + + ret+=self.getProjectsOfMember(name=x,date=date) return ret - def getProjectsOfMember(self,name=None,email=None): + def getProjectsOfMember(self,name=None,email=None,date=None): """get project of a member""" def sortP(x,y): """sort by sorting number""" @@ -588,7 +1331,8 @@ class MPIWGRoot(ZSQLExtendFolder): ret=[] splitNeu=[] if email: - members=self.ZopeFind(self.members,obj_metatypes=['MPIWGStaff'],obj_ids=[email]) + + members=self.ZopeFind(self.members,obj_metatypes=['MPIWGStaff'],obj_ids=[email],search_sub=1) name = members[0][1].title.decode('utf-8') y=name @@ -605,13 +1349,10 @@ class MPIWGRoot(ZSQLExtendFolder): if proj: proj2=[] for x in proj: - - if not((splitted[1]==" Christoph") and (splitted[0]=="Hoffmann") and (str(x.WEB_title).find('Einstein')>0)): - - #print repr(splitted[1]),repr(splitted[0]),repr(x.WEB_title) + if (not getattr(x.getObject(),'invisible',None)) and (getattr(x.getObject(),'archiveTime','')==''): + if not((splitted[1]==" Christoph") and (splitted[0]=="Hoffmann") and (str(x.WEB_title).find('Einstein')>0)): proj2.append(x) - # proj2.sort(sortP) - # ret.append((y,proj2)) + else: proj2=[] @@ -619,7 +1360,8 @@ class MPIWGRoot(ZSQLExtendFolder): if proj: names=[x.WEB_title for x in proj] for x in proj: - if not x.WEB_title in names: + + if (not x.WEB_title in names) and (getattr(x.getObject(),'archiveTime','')==''): proj2.append(x) @@ -641,6 +1383,7 @@ class MPIWGRoot(ZSQLExtendFolder): if splittedNew[0]=='': del splittedNew[0] search=string.join(splittedNew,' AND ') + if not search=='': proj=self.MembersCatalog({'title':search}) @@ -703,29 +1446,474 @@ class MPIWGRoot(ZSQLExtendFolder): return (fieldname in checkFields) - - - + def generateNameIndex(self): + """erzeuge einen index verwendeter personen""" + import psycopg + o = psycopg.connect('dbname=authorities user=dwinter password=3333',serialize=0) + results={} + print self.fulltext.historicalNames.items() + for nameItem in self.fulltext.historicalNames.items(): #gehe durch alle namen des lexikons + + c = o.cursor() + name=nameItem[0] + print "check",name + c.execute("select lastname,firstname from persons where lower(lastname) = '%s'"%quote(name)) + tmpres=c.fetchall() + firstnames=[result[1] for result in tmpres] # find all firstnames + if tmpres: + lastname=tmpres[0][0] + + for found in self.fulltext({'names':name}): + if found.getObject().isActual(): + for nh in found.getObject().getGetNeighbourhood(name, length=50,tagging=False): #hole umgebung + #schaue nun ob der vorname hinter oder vor dem name ist + position=nh.find(lastname) + # vorher + #print "NH",nh + bevorS=nh[0:position].split() + #print "BV",bevorS + if len(bevorS)>1: + try: + bevor=[bevorS[-1],bevorS[-2]] + except: + bevor=[bevorS[0]] + else: + bevor=[] + #nachher + behindS= re.split("[,|;| ]",nh[position:]) + #print "BH",behindS + if len(behindS)>2: + try: + behind=behindS[1:3] + except: + behind=[bevorS[1]] + else: + behind=[] + for firstname in firstnames: + if firstname in bevor+behind: #Namen wie mit Adelspraedikaten werden so erstmal nich gefunden + id="%s,%s"%(lastname,firstname) + if not results.has_key(id): + results[id]=[] + objId=found.getObject().getId() + if not (objId in results[id]): + print "added %s for %s"%(id,objId) + results[id].append(objId) + self.nameIndex=results + return results + def manage_addMPIWGRootForm(self): """form for adding the root""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/addMPIWGRootForm.zpt').__of__(self) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMPIWGRootForm.zpt')).__of__(self) return pt() -def manage_addMPIWGRoot(self,id,title,RESPONSE=None): +def manage_addMPIWGRoot(self,id,title,connection_id="",RESPONSE=None): """add a root folder""" newObj=MPIWGRoot(id,title) self._setObject(id,newObj) - + ob=getattr(self,id) + setattr(ob,'connection_id',connection_id) if RESPONSE is not None: RESPONSE.redirect('manage_main') -class MPIWGProject(Folder): +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 for Projects""" + + security=ClassSecurityInfo() meta_type='MPIWGProject' + 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("") + + for pubSplit in pubSplits: + pubSplit=pubSplit.replace("
","") + self.addPublication(pubSplit) + if RESPONSE: + RESPONSE.redirect('managePublications') + + + def copyImageToMargin(self,RESPONSE=None): + """copy inline images to marginal images""" + + + #getImages from WEB_project_description + description=self.getContent('WEB_project_description') + + text2=description + splitted=text2.split("""""") + + imageURLs=[] + imageCaptions=[] + for split in splitted[1:]: + tmp=split.split("
") + #return repr(splitted[1]) + try: + imageURLs.append(tmp[0].split("\"")[1].encode('utf-8')) + except: + imageURLs.append(tmp[0].split("src=")[1].split(" ")[0].encode('utf-8')) + + split2="".join(tmp[1:]) + + + splitted=split2.split("""""") + if len(splitted)>1: + tmp=splitted[1].split("
") + imageCaptions.append(tmp[0].encode('utf-8')) + + + else: + #keine caption + + imageCaptions.append("") + + + + + + + + #eintragen: + for imageURL in imageURLs: + filename=imageURL.split("/")[-1] + #lege neues images object an, mit leerem bild + + if self.ZopeFind(self,obj_ids=[filename]): + #existiert das bild schon, dann neuen filenamen + filename="project_image_"+filename + + self.addImage(None,imageCaptions[imageURLs.index(imageURL)],filename=filename) + #hole die bilddaten aus der url + url=self.absolute_url()+"/"+imageURL + #url=self.absolute_url()+"/"+filename + + try:#relative url + data=urllib.urlopen(url).read() + except: + try:#absolute + data=urllib.urlopen(self.imageURL).read() + except: + zLOG.LOG("MPIWG Project",zLOG.ERROR,"can't open: %s"%url) + + 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 hasChildren(self,date=None,onlyActive=True): + """check if project has children""" + ct=self.getContexts(childs=self.getContent('xdata_05'), + depth=1,date=date,onlyActive=onlyActive) + + if ct and len(ct)>0: + return True + else: + return False + + 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): + """Return cataloguable key for ourselves.""" + return str(self) + + def versionHeader(self): + """version Header, gibt header text entsprechend der aktuellen version aus""" + + actualTime=time.localtime() + retTXT="""""") + if len(splitted)>1: + tmp=splitted[1].split("
") + #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') + + split2="".join(tmp[1:]) + + text3=splitted[0]+split2 + + splitted=text3.split("""""") + if len(splitted)>1: + tmp=splitted[1].split("
") + self.imagecap=tmp[0].encode('utf-8') + + split4="".join(tmp[1:]) + + text5=splitted[0]+split4 + else: + #keine caption + text5=text3 + else: + #kein bild + text5=text2 + else: + text5=text2 + #teste ob WEB_project_description und keine führenden p tags - if (len(text2)>4) and (not text2[0:3]=='') and (field=='WEB_project_description'): - return "
"+text2+"
" + if (len(text5)>4) and (not text5[0:3]=='') and (field=='WEB_project_description'): + text5= "
"+text5+"
" + + + #filter image + + + return text5.encode('utf-8') + + def showImagesOfPage(self,imageUrl=None): + """show Images of project""" + 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() - return text2 def show_html(self): """simple index""" #return "HI" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/MPIWGProject_index.zpt').__of__(self) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_index.zpt')).__of__(self) return pt() + def saveFromPreview(self): + """save content aus preview""" + self.WEB_project_description=self.previewTemplate.WEB_project_description[0:] + self.REQUEST.RESPONSE.redirect("./index.html") + + def saveEditedContent(self,kupu=None,preview=None): + """save Edited content""" + + 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("./index.html") + + return True + + security.declareProtected('View management screens','edit') + 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() + + edit_MPIWGProject_main = PageTemplateFile('zpt/edit_MPIWGProject_main', globals()) + + def getPathStyle(self, path, selected, style=""): + """returns a string with the given style + 'sel' if path == selected.""" + + if path == selected: + return style + 'sel' + else: + return style + + def preview(self,description): + """preview""" + tmpPro=getattr(self,"previewTemplate",None) + if not tmpPro: + tmpPro=MPIWGProject("previewTemplate") + self._setObject("previewTemplate",tmpPro) + for field in definedFields: + setattr(tmpPro,field,getattr(self,field)) + tmpPro.WEB_project_description=description[0:] + tmpPro.invisible=True + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','previewFrame.zpt')).__of__(self) + return pt() + + #return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+"/previewTemplate") + + + 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') + + + def editMPIWGProjectForm(self): """editform""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGProject.zpt').__of__(self) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGProject.zpt')).__of__(self) return pt() - def editMPIWGProject(self,RESPONSE=None): - """edit the project""" + + def editMPIWGProject(self,RESPONSE=None,fromEdit=None): + """edit the project and archive the old version""" + + self.copyObjectToArchive() # archive the object + - #return self.REQUEST for x in definedFields: if self.REQUEST.has_key(x): setattr(self,x,[self.REQUEST[x].decode('utf-8')]) - - if RESPONSE is not None: - RESPONSE.redirect('manage_main') + if self.REQUEST.has_key('active'): + self.setActiveFlag(True) + else: + self.setActiveFlag(False) + if fromEdit and (RESPONSE is not None): + RESPONSE.redirect('./editMPIWGBasisEditor') + + else: + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + + + security.declareProtected('View managment screens','editMPIWGDisciplinesThemesEditor') + def editMPIWGDisciplinesThemesEditor(self): + """edit from edit""" + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGDisciplinesThemesNeu.zpt')).__of__(self) + return pt() + + def editMPIWGDisciplinesThemesForm(self): """edit the disciplines and themes Form""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGDisciplinesThemes.zpt').__of__(self) + + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGDisciplinesThemes.zpt')).__of__(self) return pt() - def editMPIWGDisciplinesThemes(self,disciplines=None,themes=None,RESPONSE=None): + def editMPIWGDisciplinesThemes(self,disciplines=None,themes=None,RESPONSE=None,fromEdit=None): """edit disciplin and form""" if disciplines: if type(disciplines) is StringType: @@ -886,40 +2398,54 @@ class MPIWGProject(Folder): self.xdata_10=string.join(themes,";") else: self.xdata_10="" - - if RESPONSE is not None: - RESPONSE.redirect('manage_main') + + if fromEdit and (RESPONSE is not None): + RESPONSE.redirect('./editMPIWGDisciplinesThemesEditor') + + else: + if RESPONSE is not None: + RESPONSE.redirect('manage_main') def isChecked(self,wert,list): """check if wert is in ; seperated list""" - print "W:",wert - print "L:",list,type(list) + #felder sind manchmnal als liste mit einem element definiert if type(list) is StringType or UnicodeType: splitted=list.split(";") else: splitted=list[0].split(";") - print splitted + splitted=[y.rstrip().lstrip() for y in splitted] + for x in splitted: + x=re.sub(r"[^A-z ]","",x) if (not x==u'') and x in wert: return 1 return 0 - + + security.declareProtected('View management screens','editMPIWGBasisEditor') + def editMPIWGBasisEditor(self): + """editform""" + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGBasisNeu.zpt')).__of__(self) + return pt() + + security.declareProtected('View management screens','editMPIWGBasisForm') def editMPIWGBasisForm(self): """editform""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGBasis.zpt').__of__(self) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGBasis.zpt')).__of__(self) return pt() + + security.declareProtected('View management screens','editMPIWGRelatedPublicationsForm') def editMPIWGRelatedPublicationsForm(self): """Edit related Publications""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/edit_MPIWGRelatedPublications.zpt').__of__(self) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_MPIWGRelatedPublications.zpt')).__of__(self) return pt() def loadNewFileForm(self): """Neues XML-File einlesen""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/MPIWGProject_newfile.zpt').__of__(self) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_newfile.zpt')).__of__(self) return pt() def loadNewFile(self,RESPONSE=None): @@ -947,7 +2473,7 @@ class MPIWGProject(Folder): def manage_addMPIWGProjectForm(self): """form for adding the project""" - pt=PageTemplateFile('Products/MPIWGWeb/zpt/addMPIWGProjectForm.zpt').__of__(self) + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addMPIWGProjectForm.zpt')).__of__(self) return pt() def manage_addMPIWGProject(self,id,RESPONSE=None): @@ -955,7 +2481,7 @@ def manage_addMPIWGProject(self,id,RESPO #print argv fileupload=self.REQUEST.get('fileupload',None) if fileupload: - print fileupload + file_name=fileupload.filename filedata=fileupload.read() @@ -968,6 +2494,6 @@ def manage_addMPIWGProject(self,id,RESPO self._setObject(id,newObj) - + if RESPONSE is not None: - RESPONSE.redirect('manage_main') + RESPONSE.redirect('manage_main') \ No newline at end of file