--- MPIWGWeb/MPIWGProjects.py 2006/11/08 21:04:23 1.47.2.66 +++ MPIWGWeb/MPIWGProjects.py 2007/03/23 14:16:48 1.47.2.70 @@ -167,15 +167,18 @@ class MPIWGLink(SimpleItem): if RESPONSE is not None: RESPONSE.redirect('manage') - def index_html(self): + def index_html(self,**argv): """index""" - + + + try: return self.getObj().pt_render(extra_context={'here':self}) except: self.REQUEST.RESPONSE.redirect(self.getObj().absolute_url()) + def manage_addMPIWGLinkForm(self): """Form for adding link""" pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt/AddMPIWGLink.zpt')).__of__(self) @@ -298,6 +301,7 @@ class MPIWGRoot(ZSQLExtendFolder): folders=['MPIWGProject','Folder','ECHO_Navigation'] meta_type='MPIWGRoot' + def harvestProjects(self): """harvest""" folder="/tmp" @@ -1541,10 +1545,13 @@ class MPIWGRoot(ZSQLExtendFolder): dh=getattr(self,'deletedHistoricalNames',{}) + + if type(dh) is ListType: + dh={} if not dh.has_key(name): - dh=occurrances.split("\n") + dh[name]=occurrances.split("\n") else: - dh+=occurrances.split("\n") + dh[name]+=occurrances.split("\n") self.deletedHistoricalNames=dh @@ -1718,10 +1725,15 @@ class MPIWGProject(CatalogAware,Folder): for split in splitted[1:]: tmp=split.split("

") #return repr(splitted[1]) + try: imageURLs.append(tmp[0].split("\"")[1].encode('utf-8')) except: + + try: imageURLs.append(tmp[0].split("src=")[1].split(" ")[0].encode('utf-8')) + except: + imageURLs.append("") split2="

".join(tmp[1:]) @@ -1864,16 +1876,26 @@ class MPIWGProject(CatalogAware,Folder): 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') - + """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)) + + if (getattr(self,'imageURL','')!='') or (getattr(self,'imagecap','')!='') : + try: + self.addImage(None,getattr(self,'imagecap',''),RESPONSE=None,filename=getattr(self,'imageURL','')) + except: + pass + self.imageURL='' + self.imagecap='' + images=self.ZopeFind(self,obj_metatypes=['MPIWGProject_image']) images.sort(sort_images) @@ -1903,6 +1925,7 @@ class MPIWGProject(CatalogAware,Folder): return True else: return False + def addImage(self,fileHd,caption,RESPONSE=None,filename=None): """add an MPIWG_Project_image""" @@ -1920,7 +1943,8 @@ class MPIWGProject(CatalogAware,Folder): obj.caption=caption[0:] obj.enabled=True; obj.place=self.getLastImageNumber()+1 - + obj.id=filename + if RESPONSE is not None: RESPONSE.redirect('manageImages') @@ -2312,8 +2336,11 @@ class MPIWGProject(CatalogAware,Folder): try: self.imageURL=tmp[0].split("\"")[1].encode('utf-8') except: + try: self.imageURL=tmp[0].split("src=")[1].split(" ")[0].encode('utf-8') - + except: + self.imageURL="" + split2="

".join(tmp[1:]) text3=splitted[0]+split2 @@ -2342,6 +2369,9 @@ class MPIWGProject(CatalogAware,Folder): #filter image + text5=text5.lstrip().rstrip() #loescher leerzeichen und einzelndes br + if (text5=="
") or (text5=="
"): + text5="" return text5.encode('utf-8') @@ -2462,7 +2492,9 @@ class MPIWGProject(CatalogAware,Folder): setattr(self,x,[self.REQUEST[x].decode('utf-8')]) - self.en.changeHistoricalNames(self.getId(),self.REQUEST['historicalNames'].split("\n")) + + if self.REQUEST.has_key('historicalNames'): + self.en.changeHistoricalNames(self.getId(),self.REQUEST['historicalNames'].split("\n")) if self.REQUEST.has_key('active'): self.setActiveFlag(True)