version 1.236, 2005/10/10 19:11:12
|
version 1.256, 2005/11/29 13:48:44
|
Line 67 import ECHO_helpers
|
Line 67 import ECHO_helpers
|
from ECHO_helpers import * |
from ECHO_helpers import * |
from ECHO_language import * |
from ECHO_language import * |
from ECHO_movie import * |
from ECHO_movie import * |
|
import vlp_xmlhelpers #TODO: vlp elemente aus echo herausnehmen |
#regexp for extracting elements from xml |
|
patternTXT=r"<\s*txt.*?>(.*?)</txt>" |
|
regexpTXT = re.compile(patternTXT, re.IGNORECASE + re.DOTALL) |
|
patternPage=r"<\s*page.*?>(.*?)</page>" |
|
regexpPage = re.compile(patternPage, re.IGNORECASE + re.DOTALL) |
|
|
|
|
|
|
|
Line 88 def setECHO_collectionInformation(self,t
|
Line 83 def setECHO_collectionInformation(self,t
|
self.credits=toList(credits) |
self.credits=toList(credits) |
self.weight=weight |
self.weight=weight |
|
|
|
class ECHO_partner(Image,Persistent,ECHO_basis): |
|
"""ECHO Partner""" |
|
|
|
meta_type="ECHO_partner" |
|
|
|
def __init__(self, id, title,url, file, copyrightType, person, email, country, color, content_type='', precondition=''): |
|
self.__name__=id |
|
self.title=title |
|
self.url=url |
|
self.person=person |
|
self.email=email |
|
self.country=country |
|
self.color=color |
|
self.precondition=precondition |
|
self.copyrightType=copyrightType |
|
data, size = self._read_data(file) |
|
content_type=self._get_content_type(file, data, id, content_type) |
|
self.update_data(data, content_type, size) |
|
|
|
manage_options = Image.manage_options+( |
|
{'label':'Partner Information','action':'ECHO_partner_config'}, |
|
) |
|
|
|
|
|
def changeECHO_partner(self,url,copyrightType,person, email, country, color, RESPONSE=None): |
|
"""Change main information""" |
|
self.url=url |
|
self.person=person |
|
self.email=email |
|
self.country=country |
|
self.color=color |
|
self.copyrightType=copyrightType |
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
|
def ECHO_partner_config(self): |
|
"""Main configuration""" |
|
if not hasattr(self,'url'): |
|
self.url="" |
|
pt=zptFile(self, 'zpt/ChangeECHO_partner.zpt') |
|
return pt() |
|
|
|
|
|
manage_addECHO_partnerForm=DTMLFile('dtml/ECHO_partnerAdd',globals(), |
|
Kind='ECHO_partner',kind='ECHO_partner') |
|
|
|
|
|
|
|
def manage_addECHO_partner(self, id, url, person, email, country, color, file=None, copyrightType='', title='', precondition='', content_type='', |
|
REQUEST=None): |
|
""" |
|
Add a new ECHO_partner object. |
|
|
|
Creates a new ECHO_partner object 'id' with the contents of 'file'. |
|
Based on Image.manage_addImage |
|
""" |
|
|
|
id=str(id) |
|
title=str(title) |
|
content_type=str(content_type) |
|
precondition=str(precondition) |
|
|
|
id, title = OFS.Image.cookId(id, title, file) |
|
|
|
self=self.this() |
|
|
|
# First, we create the image without data: |
|
self._setObject(id, ECHO_partner(id,title,url,'',copyrightType, person, email, country, color, content_type, precondition)) |
|
|
|
# Now we "upload" the data. By doing this in two steps, we |
|
# can use a database trick to make the upload more efficient. |
|
if file: |
|
self._getOb(id).manage_upload(file) |
|
if content_type: |
|
self._getOb(id).content_type=content_type |
|
|
|
if REQUEST is not None: |
|
try: url=self.DestinationURL() |
|
except: url=REQUEST['URL1'] |
|
REQUEST.RESPONSE.redirect('%s/manage_main' % url) |
|
return id |
|
|
class ECHO_locale(ZopePageTemplate): |
class ECHO_locale(ZopePageTemplate): |
"""localisierung""" |
"""localisierung""" |
|
|
Line 951 class ECHO_resource(CatalogAware,Folder,
|
Line 1030 class ECHO_resource(CatalogAware,Folder,
|
self.contentType=self.bib_type |
self.contentType=self.bib_type |
for data in self.metadata: |
for data in self.metadata: |
data_neu=re.sub('-','_',data) |
data_neu=re.sub('-','_',data) |
self.meta |
self.metaDataHash[data_neu]=getattr(self,data)[0:] |
DataHash[data_neu]=getattr(self,data)[0:] |
|
|
|
|
|
pt=zptFile(self, 'zpt/ChangeECHO_resource_metadata.zpt') |
pt=zptFile(self, 'zpt/ChangeECHO_resource_metadata.zpt') |
Line 1044 class ECHO_resource(CatalogAware,Folder,
|
Line 1122 class ECHO_resource(CatalogAware,Folder,
|
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
def getMDValue(self,fieldName,empty=None): |
|
|
def getMDValueSimpleSearchField(self): |
|
"""returns value for simple search""" |
|
return " ".join([self.getMDValue('title',generic="yes"), |
|
self.getMDValue('author',generic="yes"), |
|
self.getMDValue('year',generic="yes")]) |
|
|
|
def getMDValue(self,fieldNameTest,empty=None,generic=None): |
|
"""get md values""" |
|
#TODO: cache mappinghash |
|
|
|
fieldName=None |
|
if generic: |
|
if self.contentType: |
|
ct=self.contentType.replace(" ","_").lower() |
|
else: |
|
zLOG.LOG("ECHO_collection (getMDValue)", zLOG.INFO, "no_content type for %s"%self.getId()) |
|
ct="" |
|
|
|
#caching |
|
if not hasattr(self,'_v_mapHash'): #noch keine cachevariable |
|
self._v_mapHash={} |
|
|
|
tmp=self._v_mapHash.get(ct,None) |
|
if tmp: #teste ob type schon existiert |
|
fieldName=tmp.get(fieldNameTest,None) |
|
else: |
|
self._v_mapHash[ct]={} |
|
|
|
#noch nicht gecached |
|
if not fieldName and hasattr(self.standardMD,ct): |
|
fieldName=getattr(self.standardMD,ct).generateMappingHash()[fieldNameTest][0] |
|
self._v_mapHash[ct][fieldNameTest]=fieldName |
|
if not fieldName: |
|
fieldName=fieldNameTest |
if not empty: |
if not empty: |
|
#FIXME: warum gibt es manchmal kein metadatahas |
|
try: |
return self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%self.contentType) |
return self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%self.contentType) |
|
except: |
|
zLOG.LOG("ECHO (line 1069)",zLOG.ERROR,"no md hash for %s"%self.getId()) |
|
return "" |
|
|
else: |
else: |
return self.metaDataHash.get(fieldName,empty) |
|
|
return self.metaDataHash.get(fieldNameTest,empty) |
|
|
|
getFieldValue=getMDValue #depricated |
|
|
def newMetaXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None,digiliburlprefix=None): |
def newMetaXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None,digiliburlprefix=None): |
"""new index.meta""" |
"""new index.meta""" |
Line 1160 class ECHO_resource(CatalogAware,Folder,
|
Line 1280 class ECHO_resource(CatalogAware,Folder,
|
|
|
|
|
|
|
def getFieldValue(self,field): |
|
"""get value""" |
|
|
|
try: |
|
|
|
ret=self.metaDataHash[field] |
|
if ret == "": |
|
return None |
|
else: |
|
|
|
return ret |
|
except: |
|
return None |
|
|
|
def getMetaDataHash(self): |
def getMetaDataHash(self): |
"""md hash""" |
"""md hash""" |
return self.metaDataHash |
return self.metaDataHash |
|
|
def setFieldValue(self,field,value): |
def setFieldValue(self,field,value): |
"""get value""" |
"""get value""" |
|
#TODO: remove setFieldValue |
|
|
if not hasattr(self,'metaDataHash'): |
if not hasattr(self,'metaDataHash'): |
setattr(self,'metaDataHash',{}) |
setattr(self,'metaDataHash',{}) |
Line 1189 class ECHO_resource(CatalogAware,Folder,
|
Line 1296 class ECHO_resource(CatalogAware,Folder,
|
def copySearchFields(self): |
def copySearchFields(self): |
"""copys metadatafields to the object""" |
"""copys metadatafields to the object""" |
fields=['author','title','year'] |
fields=['author','title','year'] |
|
|
for field in fields: |
for field in fields: |
setattr(self,'MD_'+field,self.getFieldValue(field)) |
setattr(self,'MD_'+field,self.getMDValue(field,generic="yes")) |
|
|
|
|
def findLabelsFromMapping(self,referenceType): |
def findLabelsFromMapping(self,referenceType): |
Line 1243 class ECHO_resource(CatalogAware,Folder,
|
Line 1351 class ECHO_resource(CatalogAware,Folder,
|
|
|
|
|
|
|
|
|
|
|
bibdata={} |
bibdata={} |
retdata={} |
retdata={} |
fieldlist=self.standardMD.fieldList |
fieldlist=self.standardMD.fieldList |
Line 1294 class ECHO_resource(CatalogAware,Folder,
|
Line 1400 class ECHO_resource(CatalogAware,Folder,
|
if RESPONSE: |
if RESPONSE: |
return RESPONSE.redirect('manage_main') |
return RESPONSE.redirect('manage_main') |
|
|
def ECHO_getResourceMD(self,template="yes",back=None): |
return "OK:",self.absolute_url(),self.contentType |
|
|
|
def ECHO_getResourceMD(self,template="yes",back=None,overwrite="no"): |
"""Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource""" |
"""Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource""" |
(metadict, error)=readMetadata(self.metalink) |
(metadict, error)=readMetadata(self.metalink) |
|
|
Line 1304 class ECHO_resource(CatalogAware,Folder,
|
Line 1412 class ECHO_resource(CatalogAware,Folder,
|
if not error=="": #Fehler beim Auslesen des Metafiles |
if not error=="": #Fehler beim Auslesen des Metafiles |
return "ERROR:",error |
return "ERROR:",error |
|
|
if not self.contentType: |
if (not self.contentType) or (overwrite=="yes"): |
self.contentType=metadict['bib_type'].lower() |
self.contentType=metadict['bib_type'].lower() |
|
|
if not (metadict['bib_type'].lower()==self.contentType.lower()): |
if not (metadict['bib_type'].lower()==self.contentType.lower()): |
Line 1431 class ECHO_externalLink(Folder,ECHO_basi
|
Line 1539 class ECHO_externalLink(Folder,ECHO_basi
|
security.declarePublic('content_html') |
security.declarePublic('content_html') |
def content_html(self): |
def content_html(self): |
"""template fuer content""" |
"""template fuer content""" |
return ECHO_basis.content_html(self,'externalLink') |
ret= ECHO_basis.content_html(self,'externalLink') |
|
|
|
|
|
try: |
|
return ret.encode('utf-8') |
|
|
|
except: |
|
try: |
|
return ret.decode('latin-1') |
|
except: |
|
|
|
return ret |
|
|
def __init__(self,id,link,title,label,description,contentType,responsible,credits,weight,coords): |
def __init__(self,id,link,title,label,description,contentType,responsible,credits,weight,coords): |
|
|
Line 1505 class ECHO_link(ECHO_externalLink):
|
Line 1624 class ECHO_link(ECHO_externalLink):
|
|
|
meta_type="ECHO_link" |
meta_type="ECHO_link" |
|
|
|
manage_options = ECHO_externalLink.manage_options+( |
|
{'label':'add links config','action':'ECHO_link_addLinksForm'}, |
|
) |
|
|
|
def ECHO_link_addLinksForm(self): |
|
"""Main configuration""" |
|
|
|
pt=zptFile(self, 'zpt/ChangeECHO_link_addLinks.zpt') |
|
return pt() |
|
|
|
def ECHO_link_addLinks(self,addLinks,RESPONSE): |
|
"""add links""" |
|
self.addLinks=addLinks |
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
def content_html(self): |
def content_html(self): |
"""template fuer link""" |
"""template fuer link""" |
|
|
|
|
if hasattr(self,"link_template"): |
if hasattr(self,"link_template"): |
return ECHO_basis.content_html(self,'link') |
ret=ECHO_basis.content_html(self,'link') |
|
|
else: |
else: |
return ECHO_basis.content_html(self,'collection') |
ret=ECHO_basis.content_html(self,'collection') |
|
|
|
|
|
#return ret |
|
return ret |
|
# |
|
# |
|
# try: |
|
# return ret.decode('utf-8') |
|
# except: |
|
# try: |
|
# return ret.decode('latin-1') |
|
# except: |
|
# |
|
# return ret |
|
# |
|
|
|
|
def index_html(self): |
def index_html(self): |
"""standard link""" |
"""standard link""" |
Line 1528 class ECHO_link(ECHO_externalLink):
|
Line 1681 class ECHO_link(ECHO_externalLink):
|
else: |
else: |
params={} |
params={} |
|
|
|
if getattr(self,'addLinks','yes')=="yes": |
params['backLink']=self.aq_parent.absolute_url() |
params['backLink']=self.aq_parent.absolute_url() |
params['startLink']=splitted[0]+"?"+urllib.urlencode(params) |
params['startLink']=splitted[0]+"?"+urllib.urlencode(params) |
|
|
Line 1549 def manage_addECHO_link(self,id,title,la
|
Line 1703 def manage_addECHO_link(self,id,title,la
|
|
|
self._setObject(id,newObj) |
self._setObject(id,newObj) |
|
|
|
getattr(self,id).addLinks='no' |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
class ECHO_collection(Folder, Persistent, Implicit, Cacheable,ECHO_basis): |
class ECHO_collection(CatalogAware, Folder, Persistent, Implicit, Cacheable,ECHO_basis): |
"""ECHO Collection""" |
"""ECHO Collection""" |
|
|
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type='ECHO_collection' |
meta_type='ECHO_collection' |
|
default_catalog='resourceCatalog' |
|
|
# viewClassificationList=viewClassificationListMaster |
# viewClassificationList=viewClassificationListMaster |
displayTypes=displayTypes |
displayTypes=displayTypes |
|
|
path="/mpiwg/online/permanent/shipbuilding" |
path="/mpiwg/online/permanent/shipbuilding" |
|
|
|
def getMDValueSimpleSearchField(self): |
|
"""returns value for simple search""" |
|
return " ".join([self.title,self.description]) |
|
|
|
def getTitleAndLabel(self): |
|
"""gibt title und label zurueck""" |
|
return (getattr(self,'title',''),getattr(self,'label','')) |
|
|
def localizeObjects(self): |
def localizeObjects(self): |
"""localize all objects""" |
"""localize all objects""" |
contents=self.ZopeFind(self,obj_metatypes=['ECHO_externalLink','ECHO_link','ECHO_mapText']) |
contents=self.ZopeFind(self,obj_metatypes=['ECHO_externalLink','ECHO_link','ECHO_mapText']) |
Line 1757 class ECHO_collection(Folder, Persistent
|
Line 1923 class ECHO_collection(Folder, Persistent
|
pass |
pass |
return ret |
return ret |
|
|
def updateCollection(self,RESPONSE=None): |
def importCollection(self,path=None,RESPONSE=None): |
"""liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" |
"""liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" |
files=os.listdir(self.path) |
|
|
if path is None: |
|
pt=zptFile(self, 'zpt/importCollection.zpt') |
|
return pt() |
|
|
|
files=os.listdir(path) |
ret="" |
ret="" |
for fileName in files: |
for fileName in files: |
|
|
if fileName: |
if fileName: |
|
|
tempPath=re.sub("/mpiwg/online","",self.path) |
tempPath=re.sub("/mpiwg/online","",path) |
link="http://echo.mpiwg-berlin.mpg.de/zogilib_book?fn="+tempPath+"/"+fileName+"/pageimg" |
link="http://echo.mpiwg-berlin.mpg.de/zogilib_book?fn="+tempPath+"/"+fileName+"/pageimg" |
|
|
metalink=self.path+"/"+fileName+"/index.meta" |
metalink=self.path+"/"+fileName+"/index.meta" |
Line 1788 class ECHO_collection(Folder, Persistent
|
Line 1959 class ECHO_collection(Folder, Persistent
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
def updateCollectionMD(self,RESPONSE=None): |
|
"""updateMD""" |
|
files=os.listdir(self.path) |
|
for fileName in files: |
|
if fileName: |
|
genObj=getattr(self,fileName) |
|
genObj.copyIndex_meta2echo_resource() |
|
genObj.generate_title() |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
|
def changeViewerTemplateSetsForm(self): |
def changeViewerTemplateSetsForm(self): |
"""change the viewer template set""" |
"""change the viewer template set""" |
pt=zptFile(self, 'zpt/changeViewerTemplateSet') |
pt=zptFile(self, 'zpt/changeViewerTemplateSet') |
Line 1892 class ECHO_collection(Folder, Persistent
|
Line 2049 class ECHO_collection(Folder, Persistent
|
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
def copySearchFields(self,RESPONSE=None): |
def copySearchFields(self,RESPONSE=None): |
"""copys import metadatafields to the object""" |
"""copys < metadatafields to the object""" |
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) |
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
|
for resource in resources: |
for resource in resources: |
|
|
Line 1911 class ECHO_collection(Folder, Persistent
|
Line 2068 class ECHO_collection(Folder, Persistent
|
def reloadMetaDataFromStorage(self,RESPONSE=None): |
def reloadMetaDataFromStorage(self,RESPONSE=None): |
"""copy metadata from the storage to ECHO""" |
"""copy metadata from the storage to ECHO""" |
|
|
return reloadMetaDataFromStorage(self,RESPONSE=None) |
return reloadMetaDataFromStorage(self,RESPONSE) |
|
|
|
|
def getPartnerCopyright(self,name,sonst="generic"): |
def getPartnerCopyright(self,name,sonst="generic"): |
Line 2048 class ECHO_collection(Folder, Persistent
|
Line 2205 class ECHO_collection(Folder, Persistent
|
areas = self.getAllMapAreas() |
areas = self.getAllMapAreas() |
return self.createJSAreas(areas) |
return self.createJSAreas(areas) |
|
|
|
|
|
emptyPartner=ECHO_partner("", "","", "", "", "", "", "", "") |
|
|
security.declarePublic('getCreditObject') |
security.declarePublic('getCreditObject') |
def getCreditObject(self,name): |
def getCreditObject(self,name): |
"""credit id to credititem""" |
"""credit id to credititem""" |
try: |
try: |
return getattr(self.partners,name) |
return getattr(self.partners,name) |
except: |
except: |
return "" |
|
|
return self.emptyPartner |
|
|
|
|
security.declarePublic('ECHO_generateNavBar') |
security.declarePublic('ECHO_generateNavBar') |
def ECHO_generateNavBar(self): |
def ECHO_generateNavBar(self): |
Line 2122 class ECHO_collection(Folder, Persistent
|
Line 2284 class ECHO_collection(Folder, Persistent
|
{'label':'Set Startpage','action':'setStartpageFolderForm'}, |
{'label':'Set Startpage','action':'setStartpageFolderForm'}, |
{'label':'Change Viewer Templates and Image Viewer','action':'changeViewerTemplateSetsForm'}, |
{'label':'Change Viewer Templates and Image Viewer','action':'changeViewerTemplateSetsForm'}, |
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
{'label':'Reload Metadata','action':'reloadMetaDataFromStorageWarning'}, |
{'label':'ImportCollection','action':'updateCollection'}, |
{'label':'ImportCollection','action':'importCollection'}, |
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
) |
) |
|
|
Line 2218 class ECHO_collection(Folder, Persistent
|
Line 2380 class ECHO_collection(Folder, Persistent
|
def content_html(self,**argv): |
def content_html(self,**argv): |
"""template fuer content""" |
"""template fuer content""" |
#print "NN",argv |
#print "NN",argv |
return ECHO_basis.content_html(self,'collection') |
ret = ECHO_basis.content_html(self,'collection') |
|
|
|
try: |
|
return ret.encode('utf-8') |
|
except: |
|
|
|
try: |
|
return ret.decode('latin-1') |
|
except: |
|
|
|
return ret |
|
|
def getCredits(self): |
def getCredits(self): |
"""Ausgabe der credits""" |
"""Ausgabe der credits""" |
Line 2576 class ECHO_root(Folder,Persistent,Implic
|
Line 2748 class ECHO_root(Folder,Persistent,Implic
|
|
|
meta_type="ECHO_root" |
meta_type="ECHO_root" |
|
|
def findObjectFromFulltext(self,url=None,existUri=None): |
|
|
def mod_re_sub(self,pattern,replace,string): |
|
"""re.sub aus mod re zur Verfuegung stellen""" |
|
return re.sub(pattern,replace,string) |
|
|
|
def findObjectFromFulltext(self,existUri): |
''' |
''' |
|
|
@param url: |
@param url: |
@param existUri: |
@param existUri: |
''' |
''' |
|
|
|
if existUri: |
#TODO: at the moment assume that the filename is unique, the whole has to changed to a system of ids. |
#TODO: at the moment assume that the filename is unique, the whole has to changed to a system of ids. |
return None |
filename=existUri.split("/")[-1] |
|
|
|
founds=self.resourceCatalog.search({'fullTextUrl':os.path.splitext(filename)[0]}) |
|
|
|
ret=[(found.title,found.getObject().absolute_url(),found.getObject().aq_parent.absolute_url()) for found in founds] |
|
|
|
return ret |
|
|
def reindex(self,RESPONSE=None): |
def reindex(self,RESPONSE=None): |
"""indiziere alle Objecte neu""" |
"""indiziere alle Objecte neu""" |
Line 2595 class ECHO_root(Folder,Persistent,Implic
|
Line 2780 class ECHO_root(Folder,Persistent,Implic
|
|
|
for resource in resources: |
for resource in resources: |
resource[1].reindex() |
resource[1].reindex() |
print "<p> done %s </p>\n" |
#print "<p> done %s </p>\n" |
if RESPONSE: |
if RESPONSE: |
RESPONSE.write("<p> done %s </p>\n"%resource[0]) |
RESPONSE.write("<p> done %s </p>\n"%resource[0]) |
|
|
Line 3141 class ECHO_root(Folder,Persistent,Implic
|
Line 3326 class ECHO_root(Folder,Persistent,Implic
|
else: |
else: |
return "" |
return "" |
|
|
def link2html(self,str): |
link2html=vlp_xmlhelpers.link2html |
"""link2html fuer VLP muss hier noch raus""" |
|
if str: |
|
|
|
str=re.sub("\&","&",str) |
|
dom=xml.dom.minidom.parseString("<?xml version='1.0' encoding='utf-8'?><txt>"+str+"</txt>") |
|
links=dom.getElementsByTagName("link") |
|
|
|
|
|
for link in links: |
|
link.tagName="a" |
|
ref=link.getAttribute("ref") |
|
pn=link.getAttribute("page") |
|
|
|
if self.checkRef(ref): |
|
if pn: |
|
link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref+"&page="+pn) |
|
else: |
|
link.setAttribute("href",self.aq_parent.absolute_url()+"/references?id="+ref) |
|
|
|
|
|
newxml=dom.toxml('utf-8') |
|
|
|
retStr=regexpTXT.search(newxml) |
|
|
|
return retStr.group(1) |
|
|
|
|
|
return "" |
|
|
|
def xml2html(self,str,quote="yes"): |
|
"""link2html fuer VLP muss hier noch raus""" |
|
|
|
if str: |
|
if quote=="yes2": |
|
str=re.sub("\&","&",str) |
|
#dom=xml.dom.minidom.parseString(str) |
|
dom = NonvalidatingReader.parseString(str,"http://www.mpiwg-berlin.mpg.de/") |
|
#links=dom.getElementsByTagName("link") |
|
links=Ft.Xml.XPath.Evaluate(".//link", contextNode=dom) |
|
for link in links: |
|
#link.tagName="a" |
|
|
|
ref=link.getAttributeNS(EMPTY_NAMESPACE,"ref") |
|
pn=link.getAttributeNS(EMPTY_NAMESPACE,"page") |
|
|
|
cns=link.childNodes[0:] |
|
|
|
newLink=dom.createElementNS(EMPTY_NAMESPACE,"a") |
|
for x in cns: |
|
newLink.appendChild(x) |
|
|
|
|
|
|
|
link.parentNode.replaceChild(newLink,link) |
|
if self.checkRef(ref): |
|
if pn: |
|
newLink.setAttributeNS(EMPTY_NAMESPACE,"href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref+"&p="+pn) |
|
else: |
|
newLink.setAttributeNS(EMPTY_NAMESPACE,"href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) |
|
|
|
#str= dom.toxml('utf-8') |
|
buf = cStringIO.StringIO() |
|
PrettyPrint(dom, stream=buf) |
|
str = buf.getvalue() |
|
buf.close() |
|
#str=PrettyPrint(dom.documentElement,encoding='UTF-8') |
|
#print link.toxml('utf-8') |
|
#print type(str) |
|
retStr=regexpPage.search(str) |
|
|
|
try: # hack warum fehtl manchmal page?? |
|
return retStr.group(1) |
|
except: |
|
return str |
|
return "" |
|
|
|
def checkRef(self,ref): |
xml2html=vlp_xmlhelpers.xml2html |
if ref[0:3]=='lit': |
|
if len(self.library_data({ 'id':ref}))>0: |
|
return 1 |
|
try: |
|
if ref[0:7]=="tec_cat": |
|
return 1 |
|
except: |
|
"""nothing""" |
|
|
|
dbs={'vl_technology':'','vl_people':" AND complete='yes'",'vl_sites':''} |
checkRef=vlp_xmlhelpers.checkRef |
res=None |
|
for db in dbs.keys(): |
|
res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]))) |
|
return res |
|
|
|
#Ende Methode fuer vlp |
# def checkRef(self,ref): |
|
# if ref[0:3]=='lit': |
|
# if len(self.library_data({ 'id':ref}))>0: |
|
# return 1 |
|
# try: |
|
# if ref[0:7]=="tec_cat": |
|
# return 1 |
|
# except: |
|
# """nothing""" |
|
# |
|
# dbs={'vl_technology':'','vl_people':" AND complete='yes'",'vl_sites':''} |
|
# res=None |
|
# for db in dbs.keys(): |
|
# res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]))) |
|
# return res |
|
# |
|
# #Ende Methode fuer vlp |
|
|
def PgQuoteString(self,string): |
def PgQuoteString(self,string): |
"""Quote string""" |
"""Quote string""" |
Line 3490 def manage_addECHO_copyrightType(self,id
|
Line 3604 def manage_addECHO_copyrightType(self,id
|
|
|
|
|
|
|
class ECHO_partner(Image,Persistent,ECHO_basis): |
|
"""ECHO Partner""" |
|
|
|
meta_type="ECHO_partner" |
|
|
|
def __init__(self, id, title,url, file, copyrightType, person, email, country, color, content_type='', precondition=''): |
|
self.__name__=id |
|
self.title=title |
|
self.url=url |
|
self.person=person |
|
self.email=email |
|
self.country=country |
|
self.color=color |
|
self.precondition=precondition |
|
self.copyrightType=copyrightType |
|
data, size = self._read_data(file) |
|
content_type=self._get_content_type(file, data, id, content_type) |
|
self.update_data(data, content_type, size) |
|
|
|
manage_options = Image.manage_options+( |
|
{'label':'Partner Information','action':'ECHO_partner_config'}, |
|
) |
|
|
|
|
|
def changeECHO_partner(self,url,copyrightType,person, email, country, color, RESPONSE=None): |
|
"""Change main information""" |
|
self.url=url |
|
self.person=person |
|
self.email=email |
|
self.country=country |
|
self.color=color |
|
self.copyrightType=copyrightType |
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
|
def ECHO_partner_config(self): |
|
"""Main configuration""" |
|
if not hasattr(self,'url'): |
|
self.url="" |
|
pt=zptFile(self, 'zpt/ChangeECHO_partner.zpt') |
|
return pt() |
|
|
|
|
|
manage_addECHO_partnerForm=DTMLFile('dtml/ECHO_partnerAdd',globals(), |
|
Kind='ECHO_partner',kind='ECHO_partner') |
|
|
|
|
|
|
|
def manage_addECHO_partner(self, id, url, person, email, country, color, file=None, copyrightType='', title='', precondition='', content_type='', |
|
REQUEST=None): |
|
""" |
|
Add a new ECHO_partner object. |
|
|
|
Creates a new ECHO_partner object 'id' with the contents of 'file'. |
|
Based on Image.manage_addImage |
|
""" |
|
|
|
id=str(id) |
|
title=str(title) |
|
content_type=str(content_type) |
|
precondition=str(precondition) |
|
|
|
id, title = OFS.Image.cookId(id, title, file) |
|
|
|
self=self.this() |
|
|
|
# First, we create the image without data: |
|
self._setObject(id, ECHO_partner(id,title,url,'',copyrightType, person, email, country, color, content_type, precondition)) |
|
|
|
# Now we "upload" the data. By doing this in two steps, we |
|
# can use a database trick to make the upload more efficient. |
|
if file: |
|
self._getOb(id).manage_upload(file) |
|
if content_type: |
|
self._getOb(id).content_type=content_type |
|
|
|
if REQUEST is not None: |
|
try: url=self.DestinationURL() |
|
except: url=REQUEST['URL1'] |
|
REQUEST.RESPONSE.redirect('%s/manage_main' % url) |
|
return id |
|
|
|
class ECHO_linkList(ZopePageTemplate,ECHO_basis): |
class ECHO_linkList(ZopePageTemplate,ECHO_basis): |
"""LinkList Objekt""" |
"""LinkList Objekt""" |