|
|
| version 1.56, 2005/01/25 19:30:11 | version 1.60, 2005/02/10 16:18:15 |
|---|---|
| Line 7 import string | Line 7 import string |
| import sys | import sys |
| #from pyPgSQL import libpq | #from pyPgSQL import libpq |
| from AccessControl import getSecurityManager | from AccessControl import getSecurityManager |
| from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate | |
| from Products.PageTemplates.PageTemplateFile import PageTemplateFile | from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
| from Products.ZSQLMethods.SQL import SQLConnectionIDs | from Products.ZSQLMethods.SQL import SQLConnectionIDs |
| Line 310 class ZSQLExtendFolder(Folder,Persistent | Line 310 class ZSQLExtendFolder(Folder,Persistent |
| #print "INLINE:",query | #print "INLINE:",query |
| return self.ZSQLSimpleSearch(query) | return self.ZSQLSimpleSearch(query) |
| def ZSQLSimpleSearch(self,query=None): | def ZSQLSimpleSearch(self,query=None,max_rows=1000000): |
| """simple search""" | """simple search""" |
| if not query: | if not query: |
| query=self.query | query=self.query |
| if (hasattr(self,"_v_searchSQL") and (self._v_searchSQL == None)) or (not hasattr(self,"_v_searchSQL")): | if (hasattr(self,"_v_searchSQL") and (self._v_searchSQL == None)) or (not hasattr(self,"_v_searchSQL")): |
| self._v_searchSQL=Shared.DC.ZRDB.DA.DA("_v_searchSQL","_v_searchSQL",self.connection_id,"var","<dtml-var var>") | self._v_searchSQL=Shared.DC.ZRDB.DA.DA("_v_searchSQL","_v_searchSQL",self.connection_id,"var","<dtml-var var>") |
| self._v_searchSQL.max_rows_=max_rows | |
| try: | try: |
| return self._v_searchSQL.__call__(var=query) | return self._v_searchSQL.__call__(var=query) |
| except : | except : |
| Line 327 class ZSQLExtendFolder(Folder,Persistent | Line 328 class ZSQLExtendFolder(Folder,Persistent |
| except: pass | except: pass |
| else: | else: |
| try: | try: |
| self._v_searchSQL.max_rows_=max_rows | |
| return self._v_searchSQL.__call__(var=query) | return self._v_searchSQL.__call__(var=query) |
| except : | except : |
| if sys.exc_info()[0]=="Database Error": | if sys.exc_info()[0]=="Database Error": |
| Line 838 class ZSQLExtendFolder(Folder,Persistent | Line 840 class ZSQLExtendFolder(Folder,Persistent |
| else: | else: |
| self.REQUEST.SESSION[storename]['queryString2']=query2 | self.REQUEST.SESSION[storename]['queryString2']=query2 |
| if self.ZSQLSimpleSearch(query2): | |
| self.REQUEST.SESSION[storename]['count']=self.ZSQLSimpleSearch(query2)[0].count | self.REQUEST.SESSION[storename]['count']=self.ZSQLSimpleSearch(query2)[0].count |
| else: | |
| self.REQUEST.SESSION[storename]['count']=0 | |
| #print "QUERYNEW",self.REQUEST.SESSION[storename]['queryString2'] | #print "QUERYNEW",self.REQUEST.SESSION[storename]['queryString2'] |
| Line 1173 class ZSQLBibliography(Folder,ZSQLExtend | Line 1178 class ZSQLBibliography(Folder,ZSQLExtend |
| pt.content_type="text/html" | pt.content_type="text/html" |
| return pt() | return pt() |
| def changeZSQLBibliography(self,tableName,label,description,REQUEST=None): | def changeZSQLBibliography(self,tableName,label,description,connection_id=None,REQUEST=None): |
| """change it""" | """change it""" |
| self.connection_id=connection_id | |
| self.tableName=tableName | self.tableName=tableName |
| self.label=label | self.label=label |
| self.description=description | self.description=description |
| Line 1184 class ZSQLBibliography(Folder,ZSQLExtend | Line 1190 class ZSQLBibliography(Folder,ZSQLExtend |
| manage_options=Folder.manage_options+( | manage_options=Folder.manage_options+( |
| {'label':'Main Config','action':'changeZSQLBibliographyForm'}, | {'label':'Main Config','action':'changeZSQLBibliographyForm'}, |
| {'label':'Generate RDF Template','action':'generateRDFTemplate'}, | |
| {'label':'Generate XML Template','action':'generateXMLTemplate'}, | |
| ) | ) |
| Line 1248 class ZSQLBibliography(Folder,ZSQLExtend | Line 1256 class ZSQLBibliography(Folder,ZSQLExtend |
| return retdata,fieldlist | return retdata,fieldlist |
| def createRDFTag(self,tag,content): | def createRDFTag(self,tag,content,namespace="ns"): |
| """create RDF""" | """create RDF""" |
| if content: | if content: |
| ret=""" <cdli:%s>%s</cdli:%s>"""%(tag,content,tag) | tag=namespace+":"+tag |
| ret=""" <%s>%s</%s>"""%(tag,content,tag) | |
| return ret.decode('latin-1') | return ret.decode('latin-1') |
| else: | else: |
| return "" | return "" |
| Line 1274 class ZSQLBibliography(Folder,ZSQLExtend | Line 1283 class ZSQLBibliography(Folder,ZSQLExtend |
| pt.content_type="text/xml" | pt.content_type="text/xml" |
| return pt() | 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): | def getMetaDataRDF(self): |
| """crate index meta""" | """crate index meta""" |
| 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=PageTemplateFile(os.path.join(package_home(globals()),'zpt','record.rdf')).__of__(self) |
| pt.content_type="text/xml" | pt.content_type="text/xml" |
| return pt() | return pt() |
| else: | |
| return find[0][1]() | |
| def getMetaDataXML(self): | def getMetaDataXML(self): |
| """crate index meta""" | """crate index meta""" |
| Line 1290 class ZSQLBibliography(Folder,ZSQLExtend | Line 1329 class ZSQLBibliography(Folder,ZSQLExtend |
| else: | else: |
| return find[0][1]() | 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://xserve02.mpiwg-berlin.mpg.de:8880/cdlineu/cdli_coll/cdli2/cdli_templates/cdli_templates/textdisplay.html?-table=cdli_cat&id_text=%s"%found.id_text | |
| object="http://xserve02:8880/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://xserve02.mpiwg-berlin.mpg.de:8880/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): | def getMetaDatasXML(self): |
| """index""" | """index""" |
| Line 1361 manage_addZSQLBibliographyForm=DTMLFile( | Line 1361 manage_addZSQLBibliographyForm=DTMLFile( |
| def manage_addZSQLBibliography(self, id, tableName,label,description,title='', | def manage_addZSQLBibliography(self, id, tableName,label,description,title='', |
| createPublic=0, | createPublic=0, |
| createUserF=0, | createUserF=0, |
| connection_id=None, | |
| REQUEST=None): | REQUEST=None): |
| """Add a new Folder object with id *id*. | """Add a new Folder object with id *id*. |
| Line 1378 def manage_addZSQLBibliography(self, id, | Line 1379 def manage_addZSQLBibliography(self, id, |
| setattr(ob,'tableName',tableName) | setattr(ob,'tableName',tableName) |
| setattr(ob,'label',label) | setattr(ob,'label',label) |
| setattr(ob,'description',description) | setattr(ob,'description',description) |
| setattr(ob,'connection_id',connection_id) | |
| checkPermission=getSecurityManager().checkPermission | checkPermission=getSecurityManager().checkPermission |