--- MPIWGWeb/MPIWGStaff.py 2009/04/17 14:29:13 1.10.2.66 +++ MPIWGWeb/MPIWGStaff.py 2012/01/02 17:14:44 1.10.2.77 @@ -25,6 +25,7 @@ import logging import email import re from OFS.Cache import Cacheable +import urllib2 from MPIWGHelper import * #ersetzt logging @@ -33,11 +34,11 @@ def logger(txt,method,txt2): logging.info(txt+ txt2) departmentList="Renn\nRheinberger\nDaston\nKlein\nSibum\nIT\nInstitut\nBibliothek" +coneService="http://127.0.0.1:8280/MetaDataManagerRestlet/cone/" - -def createNewDBEntry(self,publish_the_data,key,name,vorname,title,position,e_mail,e_mail_p,date_from,date_to,abteilung,heimat_inst,funded_by="",e_mail2="",txt="",txt_p="no",stay_at_mpiwg="",group="",web_object_created="no",current_work=""): +def createNewDBEntry(self,publish_the_data,key,name,vorname,titles_new,position,e_mail,e_mail_p,date_from,date_to,abteilung,heimat_inst,funded_by="",e_mail2="",txt="",txt_p="no",stay_at_mpiwg="",group="",web_object_created="no",current_work=""): """lege person in der datenbank an""" if date_to=="": # wenn date_to leer @@ -51,8 +52,8 @@ def createNewDBEntry(self,publish_the_da return False,"ERROR:key%s already exists"%key #eintragen - columnlist="""publish_the_data,key,last_name,first_name,title,status,e_mail,e_mail_p,date_from,date_to,department,home_inst,funded_by,e_mail2,date_stay_at_mpiwg,web_object_created,"group",current_work,current_work_p """ - insertTuple=(publish_the_data,key,name,vorname,title,position,e_mail,e_mail_p,date_from,date_to,abteilung,heimat_inst,funded_by,e_mail2,stay_at_mpiwg,web_object_created,group,current_work,"yes") + columnlist="""publish_the_data,key,last_name,first_name,titles_new,status,e_mail,e_mail_p,date_from,date_to,department,home_inst,funded_by,e_mail2,date_stay_at_mpiwg,web_object_created,"group",current_work,current_work_p """ + insertTuple=(publish_the_data,key,name,vorname,titles_new,position,e_mail,e_mail_p,date_from,date_to,abteilung,heimat_inst,funded_by,e_mail2,stay_at_mpiwg,web_object_created,group,current_work,"yes") insert=[] for element in insertTuple: @@ -79,6 +80,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend meta_type="MPIWGStaff" default_catalog='MembersCatalog' departmentList=departmentList + _v_cone=None; security=ClassSecurityInfo() def redirect(self,RESPONSE,url): @@ -121,6 +123,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend return root.getConnectionObj() except: return self.en.getConnectionObj() + def isPublished(self): """gib publications status aus der datenbank aus""" key=self.getKey() @@ -235,7 +238,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend """publish the image??, default no""" return getattr(self,'publishImage','no') - def updateImage(self,file,publishImage,rename=None,RESPONSE=None): + def updateImage(self,publishImage,file=None,rename=None,RESPONSE=None): """update image""" if file and not(file.filename==""): @@ -316,6 +319,20 @@ class MPIWGStaff(CatalogAware,ZSQLExtend """ return self.id + def getConeUrl(self): + """gibt coneURL zurueck""" + if self._v_cone==None: + try: + cone = urllib2.urlopen(coneService+self.getPersonID()) + self._v_cone=cone.read() + except: + return None + + return self._v_cone + + + + def harvest_page_old(self,context=None): """geharvestete seite = verschlankte version von members_main""" #pt = getTemplate(self, "harvest_members_main") @@ -339,7 +356,8 @@ class MPIWGStaff(CatalogAware,ZSQLExtend """harvest""" if not self.isPublished(): return "" - return getattr(self.en.staff.members,self.getId()).index_html() + st = getattr(self.en.staff.members,self.getId()).index_html() + return st def index_html(self): @@ -367,9 +385,14 @@ class MPIWGStaff(CatalogAware,ZSQLExtend if result is not None: # Got a cached value. return result - - pt = getTemplate(self, "members_main") - # Execute the template in a new security context. + + # look for individual page + if self.hasObject("index.html"): + pt = getattr(self, "index.html") + # else use template + else: + pt = getTemplate(self, "members_main") + # Execute the template in a new security context. security.addContext(self) try: @@ -449,7 +472,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMPIWGStaff.zpt')).__of__(self) - logging.error("XX:"+email.Utils.formatdate().split("-")[0]+'GMT') + logging.debug("XX:"+email.Utils.formatdate().split("-")[0]+'GMT') return pt() mainEditFile=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMPIWGStaff_main.zpt')) @@ -578,7 +601,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend """get the profile""" self.REQUEST.RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT') - founds=self.ZSQLInlineSearchU(_table='personal_www',key=self.getKey()) + founds=self.ZSQLInlineSearchU(_table='personal_www',key=self.getKeyUTF8()) html="""%s""" if founds.profile and founds.profile != "": @@ -630,6 +653,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend """erzeugt ein automatisches Profil aus den alten Eintraegen CV, Current work, und research interests""" ret="" + #founds=self.ZSQLInlineSearch(_table='research_interest',key_main=person.getKeyUTF8()) founds=self.ZSQLInlineSearch(_table='research_interest',key_main=person.key) if founds: ret="

Research interests:


" @@ -706,7 +730,7 @@ class MPIWGStaff(CatalogAware,ZSQLExtend pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','editMainData.zpt')).__of__(self) return pt() else: - self.ZSQLChange(argv,_table="personal_www",_identify="key=%s"%self.getKeyUTF8(),USE_FORM="yes") + self.ZSQLChange(argv,_table="personal_www",_identify="lower(key)=%s"%utf8ify(self.getKey().lower()),USE_FORM="yes") if RESPONSE: self.redirect(RESPONSE,"editMainData")