--- MPIWGWeb/MPIWGProjects.py 2005/10/17 11:05:46 1.47.2.35 +++ MPIWGWeb/MPIWGProjects.py 2006/01/16 15:21:47 1.47.2.47 @@ -762,10 +762,10 @@ class MPIWGRoot(ZSQLExtendFolder): def updateHomepages(self,RESPONSE=None): """ update""" - #FIXME: seite wird hinter apache mehrfach ausgefŸhrt + 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=10000&-findall" + 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) @@ -787,6 +787,7 @@ class MPIWGRoot(ZSQLExtendFolder): 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]) @@ -796,7 +797,7 @@ class MPIWGRoot(ZSQLExtendFolder): 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: @@ -822,10 +823,10 @@ class MPIWGRoot(ZSQLExtendFolder): RESPONSE.write("

new:%s

\n"%username.encode('utf-8')) obj=getattr(memberFolder,username) ret=obj.createNewDBEntry(publish_the_data,id,name, - vorname,username,title,e_mail, + vorname,username,title,position,e_mail, e_mail_p,date_from,date_to, abteilung,heimat_inst,funded_by, - e_mail2,txt,txt_p) + 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'))) @@ -849,17 +850,31 @@ class MPIWGRoot(ZSQLExtendFolder): obj=getattr(memberFolder,username) - obj.updateDBEntry(DBid=id,publish_the_data=publish_the_data, + done= obj.updateDBEntry(DBid=id,publish_the_data=publish_the_data, date_from=date_from, - date_to=date_to) + 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,stay_at_mpiwg) + if not ret[0]: + + RESPONSE.write("

Error: %s

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

New: %s

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

Done

") + #self.updatePublicationDB() + + #self.ZSQLResetConnection() + RESPONSE.write("

Done

") - + return True def reindexCatalogs(self,RESPONSE=None): """reindex members and project catalog""" @@ -1015,7 +1030,7 @@ class MPIWGRoot(ZSQLExtendFolder): ret+="""
  • \n""" if actualDepth==1: - departmentName={'1':'Department I','2':'Department II','3':'Department III', '4':'Ind. Research Group','5':'Ind. Research Group'} + departmentName={'1':'Department I','2':'Department II','3':'Department III', '4':'Ind. Research Group','5':'Ind. Research Group','6':'Research Network'} department=element[3].getContent('xdata_05') ret+="""
    %s: """%(department,departmentName[department]) @@ -1033,6 +1048,8 @@ class MPIWGRoot(ZSQLExtendFolder): return """

    Ind. Research Group I: %s

    """%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) if element[3].getContent('xdata_05') == "5": return """

    Ind. Research Group II: %s

    """%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) + if element[3].getContent('xdata_05') == "6": + return """

    Research Network "History of Scientific Objects": %s

    """%(element[3].absolute_url()+"/index.html",element[3].getContent('WEB_title')) return """

    Department %s: %s

    """%(element[3].absolute_url()+"/index.html",element[3].getContent('xdata_05'),element[3].getContent('WEB_title')) @@ -1395,33 +1412,70 @@ class MPIWGProject(CatalogAware,Folder): RESPONSE.redirect('managePublications') - def copyImageToMargin(self,RESPONSE=None): - #TODO: copy more than one image + def copyImageToMargin(self,RESPONSE=None): """copy inline images to marginal images""" - self.getContent('WEB_project_description',filter='yes') + + + #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')) + - filename=self.imageURL.split("/")[-1] - #lege neues images object an, mit leerem bild + else: + #keine caption + + imageCaptions.append("") + + - 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 - url=self.absolute_url()+"/"+self.imageURL - #url=self.absolute_url()+"/"+filename - try:#relative url - data=urllib.urlopen(url).read() - except: - try:#absolute - data=urllib.urlopen(self.imageURL).read() + + + + #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: - zLOG.LOG("MPIWG Project",zLOG.ERROR,"can't open: %s"%url) + 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) + obj=getattr(self,filename) + obj.update_data(data) if RESPONSE: RESPONSE.redirect('manageImages') @@ -1904,7 +1958,7 @@ class MPIWGProject(CatalogAware,Folder): start=kupu.find("") end=kupu.find("") newcontent= kupu[start+6:end] - + if preview: return self.preview(newcontent) @@ -1925,6 +1979,16 @@ class MPIWGProject(CatalogAware,Folder): 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""" @@ -1935,7 +1999,7 @@ class MPIWGProject(CatalogAware,Folder): 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()