--- ECHO_content/VLPExtension.py 2004/05/27 09:31:25 1.2 +++ ECHO_content/VLPExtension.py 2004/06/08 15:25:11 1.6 @@ -13,9 +13,111 @@ def getText(nodelist): rc = rc + node.data return rc +class VLP_essay(Folder): + """classe für VLP essays""" + + meta_type="VLP_essay" + + def __init__(self,id,title,label): + """init""" + self.id=id + self.title=title + self.label=label + + def getPage(self,pagenum): + """gibt essay page mit num aus""" + def sortFind(x,y): + return cmp(x[0],y[0]) + + pages=self.ZopeFind(self,obj_metatypes=['DTML Document','File']) + + pages.sort(sortFind) + #print str(pages[int(pagenum)][1]()) + if pages[int(pagenum)-1][1].meta_type=='File': + return str(pages[int(pagenum)-1][1]) + else: + return str(pages[int(pagenum)-1][1]()) + + def nextPage(self,pagenum,url): + pages=len(self.ZopeFind(self,obj_metatypes=['DTML Document'])) # teste ob performance ok, sonst in variable + if int(pagenum)+1 <= pages: + retstr=url+"?p="+str(int(pagenum)+1) + return """next"""%retstr + + def previousPage(self,pagenum,url): + pages=len(self.ZopeFind(self,obj_metatypes=['DTML Document'])) # teste ob performance ok, sonst in variable + if int(pagenum)-1 > 0: + retstr=url+"?p="+str(int(pagenum)-1) + return """previous"""%retstr + + +def manage_addVLP_essayForm(self): + """Form for adding""" + pt=PageTemplateFile('Products/ECHO_content/vlp/AddVLP_essay.zpt').__of__(self) + return pt() + +def manage_addVLP_essay(self, id,title,label,RESPONSE=None): + """add the copyright""" + + + self._setObject(id, VLP_essay(id, title,label)) + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + + class VLP_collection(ECHO_collection): """VLP spezifische Erweiterung der Collection""" + meta_type="VLP_collection" + manage_options=ECHO_collection.manage_options+( + {'label':'Change Path','action':'VLP_path_configForm'}, + {'label':'Update Library','action':'updateCollection'}, + {'label':'Update Metadata','action':'updateCollectionMD'}, + ) + + def VLP_path_configForm(self): + """change pt""" + path=PageTemplateFile('Products/ECHO_content/vlp/ChangeVLPPath.zpt').__of__(self) + return pt() + + def VLP_path_config(self,path,RESPONSE=None): + """config""" + self.path=path + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + def updateCollection(self,RESPONSE=None): + """liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" + files=os.listdir(self.path) + for fileName in files: + + if fileName[0:3]=="lit": + + metalink=self.REQUEST['URL1']+"/"+fileName+"/index_meta" + newObj=VLP_resource(fileName,'',metalink,fileName,fileName,fileName,'generated','book','','','','','','') + self._setObject(fileName,newObj) + + genObj=getattr(self,fileName) + genObj.createIndexFile() + + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + def updateCollectionMD(self,RESPONSE=None): + """updateMD""" + files=os.listdir(self.path) + for fileName in files: + if fileName[0:3]=="lit": + genObj=getattr(self,fileName) + genObj.copyIndex_meta2echo_resource() + genObj.generate_title() + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + def manage_addVLP_collectionForm(self): """Form for adding a ressource""" @@ -24,13 +126,14 @@ def manage_addVLP_collectionForm(self): -def manage_addVLP_collection(self,id,title,label,description,contentType,responsible,weight,sortfield,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour=""): +def manage_addVLP_collection(self,id,title,label,description,contentType,responsible,weight,sortfield,path,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour=""): """add a echo collection""" newObj=VLP_collection(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag,bgcolour="") self._setObject(id,newObj) + setattr(newObj,'path',path) if RESPONSE is not None: RESPONSE.redirect('manage_main') @@ -83,6 +186,7 @@ class VLP_resource(ECHO_resource): pt.content_type="text/html" return pt() + index_html=show def index_meta(self): """index_meta"""