--- ECHO_content/VLPExtension.py 2004/11/29 20:39:25 1.36 +++ ECHO_content/VLPExtension.py 2005/02/28 20:02:08 1.41 @@ -338,10 +338,33 @@ def manage_addVLP_encyc(self, id,title,l if RESPONSE is not None: RESPONSE.redirect('manage_main') +class VLP_subcollection(ECHO_collection): + """ subcollection of elements""" + + meta_type="VLP_subcollection" + def generateSubCollectionFromDB(self): + """erzeuge subcollection""" + for item in self.ZSQLSimpleSearch("select * from vl_literature where volumeid like '%s'"%self.id): + manage_addECHO_link(self,item.reference,item.titlerefdisplay,item.titlerefdisplay) + + def index_html(self): + """erzeuge darstellung""" + pt=zptFile(self, 'vlp/collection_template.zpt') + return pt() + + +def manage_addVLP_subCollection(self,id,title,label,RESPONSE=None): + + self._setObject(id,VLP_subcollection(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'}, @@ -349,6 +372,24 @@ class VLP_collection(ECHO_collection): {'label':'Update Metadata','action':'updateCollectionMD'}, ) + + def generateSubCollections(self): + """erzeuge subcollectionen""" + founds=self.ZSQLSimpleSearch("select * from vl_literature where referencetype in ('(Book)','(Collection)','(Journal)','(Library)')") + + self.REQUEST.RESPONSE.write("\n") + for found in founds: + + foundCol=self.ZopeFind(self,obj_ids=[found.reference]) + if foundCol: + self.manage_delObjects([foundCol[0][0]]) + + manage_addVLP_subCollection(self,found.reference,found.titlerefdisplay,found.titlerefdisplay) + #getattr(self,found.reference).generateSubCollectionFromDB() + + self.REQUEST.RESPONSE.write("

%s

\n"%found.reference) + + def VLP_path_configForm(self): """change pt""" path=PageTemplateFile(os.path.join(package_home(globals()),'vlp','ChangeVLPPath.zpt')).__of__(self) @@ -371,12 +412,10 @@ class VLP_collection(ECHO_collection): if not hasattr(self,fileName): newObj=VLP_resource(fileName,'',metalink,fileName,fileName,fileName,'generated','book','','','','','','') self._setObject(fileName,newObj) - + RESPONSE.write("got: %s\n"%fileName) genObj=getattr(self,fileName) genObj.createIndexFile() - - if RESPONSE is not None: RESPONSE.redirect('manage_main') @@ -473,32 +512,39 @@ class VLP_resource(ECHO_resource,Cacheab def copyTranscriptionFromDB(self): """checks if transcription exits in DB""" - founds=self.search(var='select * from vl_transcript where source=\''+self.resourceID+'\' order by id') + founds=self.ZSQLSimpleSearch('select * from vl_transcript where source=\''+self.resourceID+'\' order by id') + - ret=""" """ if founds: for found in founds: + text=found.transcript if not text: text="" ret+=""+text+"" ret+="" re2=ret[0:] - re3=re2.decode('latin-1') - + re3=re2.decode('latin-1').encode('utf-8') + #re3=re2 ft=self.ZopeFind(self,obj_metatypes=['ECHO_fullText']) if ft: - ft[0][1].pt_edit(re3.encode('utf-8','ignore'),'text/xml') + ft[0][1].pt_edit(re3,'text/xml') else: - self._setObject('fulltext',ECHO_fullText(id,re3)) - + + self._setObject('fulltext',ECHO_fullText(id,'')) + + try: + getattr(self,'fulltext').pt_edit(re3.encode('utf-8','ignore'),'text/xml') + except: + getattr(self,'fulltext').pt_edit(re3.encode('latin-1').decode('utf-8'),'text/xml') + return "FT: %s"%self.getId() else: return "no: %s"%self.getId() @@ -529,8 +575,14 @@ class VLP_resource(ECHO_resource,Cacheab pt=PageTemplateFile(os.path.join(package_home(globals()),'vlp','library_template.zpt')).__of__(self) pt.content_type="text/html" return pt() - - index_html=show + + def index_html(self): + """index_html""" + #return self.REQUEST + if not self.REQUEST.has_key("ws"): + self.REQUEST.form["ws"]="1.5" + + return self.show() def generateLibraryTemplateHTML(self,RESPONSE=None): """lege standard index.html an""" @@ -571,6 +623,8 @@ class VLP_resource(ECHO_resource,Cacheab def dir2index(self): """dir to index""" + excludeNames=['Icon'] + def calculateName(str): name=os.path.splitext(str[1:])[0] ret="%s: %s"%(str[0],name) @@ -585,7 +639,7 @@ class VLP_resource(ECHO_resource,Cacheab temp=[] ret.sort() for x in ret: - if not (x[0]=="."): + if (not (x[0]==".")) and (not x in excludeNames): temp.append((calculateName(x),os.path.splitext(x)[0])) return temp