--- ZSQLExtend/ZSQLExtend.py 2005/02/08 16:12:54 1.58 +++ ZSQLExtend/ZSQLExtend.py 2005/02/09 20:10:42 1.59 @@ -7,7 +7,7 @@ import string import sys #from pyPgSQL import libpq from AccessControl import getSecurityManager - +from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.ZSQLMethods.SQL import SQLConnectionIDs @@ -1175,8 +1175,9 @@ class ZSQLBibliography(Folder,ZSQLExtend pt.content_type="text/html" return pt() - def changeZSQLBibliography(self,tableName,label,description,REQUEST=None): + def changeZSQLBibliography(self,tableName,label,description,connection_id=None,REQUEST=None): """change it""" + self.connection_id=connection_id self.tableName=tableName self.label=label self.description=description @@ -1186,6 +1187,8 @@ class ZSQLBibliography(Folder,ZSQLExtend manage_options=Folder.manage_options+( {'label':'Main Config','action':'changeZSQLBibliographyForm'}, + {'label':'Generate RDF Template','action':'generateRDFTemplate'}, + {'label':'Generate XML Template','action':'generateXMLTemplate'}, ) @@ -1276,11 +1279,41 @@ class ZSQLBibliography(Folder,ZSQLExtend pt.content_type="text/xml" return pt() + + def generateRDFTemplate(self,REQUEST=None): + """generateRDFtemplate""" + zt=ZopePageTemplate('record.rdf') + self._setObject('record.rdf',zt) + default_content_fn = os.path.join(package_home(globals()), + 'zpt','record.rdf') + text = open(default_content_fn).read() + zt.pt_edit(text, 'text/xml') + + + if REQUEST is not None: + return self.manage_main(self, REQUEST) + + def generateXMLTemplate(self,REQUEST=None): + """generateXMLtemplate""" + zt=ZopePageTemplate('record.xml') + self._setObject('record.xml',zt) + default_content_fn = os.path.join(package_home(globals()), + 'zpt','record.xml') + text = open(default_content_fn).read() + zt.pt_edit(text, 'text/xml') + + + if REQUEST is not None: + return self.manage_main(self, REQUEST) def getMetaDataRDF(self): """crate index meta""" - pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','record.rdf')).__of__(self) - pt.content_type="text/xml" - return pt() + find=self.ZopeFind(self,obj_ids=["record.rdf"]) + if not find: + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','record.rdf')).__of__(self) + pt.content_type="text/xml" + return pt() + else: + return find[0][1]() def getMetaDataXML(self): """crate index meta""" @@ -1292,45 +1325,6 @@ class ZSQLBibliography(Folder,ZSQLExtend else: return find[0][1]() - def createVLMAtripels(self): - """index""" - # check if the request's host part was OK - http_host = self.REQUEST['HTTP_HOST'] - host_port = self.REQUEST['SERVER_PORT'] - fix_host = None - if http_host and http_host.rfind(host_port) == -1: - print "HTTP_HOST needs fixing!" - fix_host = http_host + ":" + host_port - - ret="" - for found in self.ZSQLSimpleSearch("select id_text from %s limit ALL"%'cdli_cat'): - base_url = self.absolute_url() - if fix_host: - #print "replacing ", http_host, " by ", fix_host - base_url = string.replace(base_url, http_host, fix_host, 1) - - #found2=self.ZSQLInlineSearchU(_table="cdli_imglist",id_text=found.id_text) - #create collectionobject info - subject="http://141.14.237.222:8080/cdlineu/cdli_coll/cdli2/cdli_templates/cdli_templates/textdisplay.html?-table=cdli_cat&id_text=%s"%found.id_text - object="http://141.14.237.222:8080/cdlidata/images/getMetaDataRDF?id_text=%s"%found.id_text - predicate="metadata" - ret+="%s\t%s\t%s\n"%(subject,object,predicate) - #create image - subject="http://141.14.237.222:8080/cdlineu/cdli_coll/cdli2/cdli_templates/cdli_templates/textdisplay.html?-table=cdli_cat&id_text=%s"%found.id_text - object="http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=/experimental/cdli/dl/photo/%s&mo=rawfile"%found.id_text - predicate="image" - - ret+="%s\t%s\t%s\n"%(subject,object,predicate) - - #create thumb - subject="http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=/experimental/cdli/dl/photo/%s&mo=rawfile"%found.id_text - object="http://nausikaa2.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler?fn=/experimental/cdli/dl/photo/%s&dw=100&dh=100"%found.id_text - predicate="thumb" - - ret+="%s\t%s\t%s\n"%(subject,object,predicate) - - return ret - def getMetaDatasXML(self): """index""" @@ -1363,6 +1357,7 @@ manage_addZSQLBibliographyForm=DTMLFile( def manage_addZSQLBibliography(self, id, tableName,label,description,title='', createPublic=0, createUserF=0, + connection_id=None, REQUEST=None): """Add a new Folder object with id *id*. @@ -1380,6 +1375,7 @@ def manage_addZSQLBibliography(self, id, setattr(ob,'tableName',tableName) setattr(ob,'label',label) setattr(ob,'description',description) + setattr(ob,'connection_id',connection_id) checkPermission=getSecurityManager().checkPermission