version 1.248, 2005/11/03 15:58:16
|
version 1.256, 2005/11/29 13:48:44
|
Line 83 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 1039 class ECHO_resource(CatalogAware,Folder,
|
Line 1123 class ECHO_resource(CatalogAware,Folder,
|
|
|
|
|
|
|
|
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,fieldName,empty=None,generic=None): |
def getMDValue(self,fieldNameTest,empty=None,generic=None): |
"""get md values""" |
"""get md values""" |
#TODO: cache mappinghash |
#TODO: cache mappinghash |
|
|
|
fieldName=None |
if generic: |
if generic: |
|
if self.contentType: |
ct=self.contentType.replace(" ","_").lower() |
ct=self.contentType.replace(" ","_").lower() |
|
else: |
|
zLOG.LOG("ECHO_collection (getMDValue)", zLOG.INFO, "no_content type for %s"%self.getId()) |
|
ct="" |
|
|
#caching |
#caching |
if not hasattr(self,'_v_mapHash'): #noch keine cachevariable |
if not hasattr(self,'_v_mapHash'): #noch keine cachevariable |
Line 1062 class ECHO_resource(CatalogAware,Folder,
|
Line 1155 class ECHO_resource(CatalogAware,Folder,
|
if not fieldName and hasattr(self.standardMD,ct): |
if not fieldName and hasattr(self.standardMD,ct): |
fieldName=getattr(self.standardMD,ct).generateMappingHash()[fieldNameTest][0] |
fieldName=getattr(self.standardMD,ct).generateMappingHash()[fieldNameTest][0] |
self._v_mapHash[ct][fieldNameTest]=fieldName |
self._v_mapHash[ct][fieldNameTest]=fieldName |
|
if not fieldName: |
|
fieldName=fieldNameTest |
if not empty: |
if not empty: |
#FIXME: warum gibt es manchmal kein metadatahas |
#FIXME: warum gibt es manchmal kein metadatahas |
try: |
try: |
Line 1070 class ECHO_resource(CatalogAware,Folder,
|
Line 1164 class ECHO_resource(CatalogAware,Folder,
|
except: |
except: |
zLOG.LOG("ECHO (line 1069)",zLOG.ERROR,"no md hash for %s"%self.getId()) |
zLOG.LOG("ECHO (line 1069)",zLOG.ERROR,"no md hash for %s"%self.getId()) |
return "" |
return "" |
|
|
else: |
else: |
return self.metaDataHash.get(fieldName,empty) |
|
|
return self.metaDataHash.get(fieldNameTest,empty) |
|
|
getFieldValue=getMDValue #depricated |
getFieldValue=getMDValue #depricated |
|
|
Line 1317 class ECHO_resource(CatalogAware,Folder,
|
Line 1413 class ECHO_resource(CatalogAware,Folder,
|
return "ERROR:",error |
return "ERROR:",error |
|
|
if (not self.contentType) or (overwrite=="yes"): |
if (not self.contentType) or (overwrite=="yes"): |
self.contentType=metadict['bib_type'] |
self.contentType=metadict['bib_type'].lower() |
|
|
if not (metadict['bib_type'].lower()==self.contentType.lower()): |
if not (metadict['bib_type'].lower()==self.contentType.lower()): |
self.REQUEST.SESSION['contentStorage']=metadict['bib_type'] |
self.REQUEST.SESSION['contentStorage']=metadict['bib_type'] |
Line 1443 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 1516 class ECHO_link(ECHO_externalLink):
|
Line 1623 class ECHO_link(ECHO_externalLink):
|
"""external_link""" |
"""external_link""" |
|
|
meta_type="ECHO_link" |
meta_type="ECHO_link" |
|
|
manage_options = ECHO_externalLink.manage_options+( |
manage_options = ECHO_externalLink.manage_options+( |
{'label':'add links config','action':'ECHO_link_addLinksForm'}, |
{'label':'add links config','action':'ECHO_link_addLinksForm'}, |
) |
) |
Line 1535 class ECHO_link(ECHO_externalLink):
|
Line 1643 class ECHO_link(ECHO_externalLink):
|
def content_html(self): |
def content_html(self): |
"""template fuer link""" |
"""template fuer link""" |
|
|
|
|
if hasattr(self,"link_template"): |
if hasattr(self,"link_template"): |
ret=ECHO_basis.content_html(self,'link') |
ret=ECHO_basis.content_html(self,'link') |
|
|
else: |
else: |
ret=ECHO_basis.content_html(self,'collection') |
ret=ECHO_basis.content_html(self,'collection') |
|
|
try: |
|
return ret.decode('utf-8') |
#return ret |
except: |
|
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 1588 def manage_addECHO_link(self,id,title,la
|
Line 1709 def manage_addECHO_link(self,id,title,la
|
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): |
def getTitleAndLabel(self): |
"""gibt title und label zurueck""" |
"""gibt title und label zurueck""" |
return (getattr(self,'title',''),getattr(self,'label','')) |
return (getattr(self,'title',''),getattr(self,'label','')) |
Line 1796 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 1827 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 1931 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'],search_sub=1) |
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
|
for resource in resources: |
for resource in resources: |
Line 2087 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 2161 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 2626 class ECHO_root(Folder,Persistent,Implic
|
Line 2749 class ECHO_root(Folder,Persistent,Implic
|
meta_type="ECHO_root" |
meta_type="ECHO_root" |
|
|
|
|
|
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): |
def findObjectFromFulltext(self,existUri): |
''' |
''' |
|
|
Line 2653 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 3477 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""" |