version 1.79, 2007/01/23 18:22:29
|
version 1.85, 2007/08/15 11:05:43
|
Line 17 import ECHO_collection
|
Line 17 import ECHO_collection
|
import base64 |
import base64 |
import bz2 |
import bz2 |
import xmlrpclib |
import xmlrpclib |
import zLOG |
|
import logging |
import logging |
|
|
|
#erstzt logging |
|
def logger(txt,method,txt2): |
|
"""logging""" |
|
logging.info(txt+ txt2) |
|
|
displayTypes = ['ZSQLExtendFolder','ZSQLBibliography','ECHO_group','ECHO_collection','ECHO_resource','ECHO_link','ECHO_sqlElement','ECHO_pageTemplate','ECHO_externalLink','ImageCollectionIFrame','VLP_resource','VLP_essay','ECHO_ZCatalogElement','ImageCollection','versionedFileFolder','ECHO_movie'] |
displayTypes = ['ZSQLExtendFolder','ZSQLBibliography','ECHO_group','ECHO_collection','ECHO_resource','ECHO_link','ECHO_sqlElement','ECHO_pageTemplate','ECHO_externalLink','ImageCollectionIFrame','VLP_resource','VLP_essay','ECHO_ZCatalogElement','ImageCollection','versionedFileFolder','ECHO_movie'] |
|
|
|
|
Line 30 def encodeRPC(string):
|
Line 35 def encodeRPC(string):
|
def decodeRPC(string): |
def decodeRPC(string): |
return bz2.decompress(base64.decodestring(string)) |
return bz2.decompress(base64.decodestring(string)) |
|
|
|
def unicodify(s): |
|
"""decode str (utf-8 or latin-1 representation) into unicode object""" |
|
if not s: |
|
return u"" |
|
if isinstance(s, str): |
|
try: |
|
return s.decode('utf-8') |
|
except: |
|
return s.decode('latin-1') |
|
else: |
|
return s |
|
|
|
def utf8ify(s): |
|
"""encode unicode object or string into byte string in utf-8 representation. |
|
assumes string objects to be utf-8""" |
|
if not s: |
|
return "" |
|
if isinstance(s, str): |
|
return s |
|
else: |
|
return s.encode('utf-8') |
|
|
|
|
def content_html(self,type): |
def content_html(self,type): |
"""template fuer content""" |
"""template fuer content""" |
#templates = self.ZopeFind(self.aq_parent,obj_ids=[type+"_template"]) |
#templates = self.ZopeFind(self.aq_parent,obj_ids=[type+"_template"]) |
Line 56 class ECHO_basis:
|
Line 84 class ECHO_basis:
|
management_page_charset="utf-8" |
management_page_charset="utf-8" |
isVisible = True |
isVisible = True |
|
|
|
|
|
def unicodify(self, s): |
|
"""return unicode object for string (utf-8 or latin1) or unicode object s""" |
|
return unicodify(s) |
|
|
|
|
|
def utf8ify(self, s): |
|
"""return utf-8 encoded string object for string or unicode object s""" |
|
return utf8ify(s) |
|
|
|
|
def manage_addECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): |
def manage_addECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): |
return ECHO_collection.manage_addECHO_locale(self,lang,title,label) |
return ECHO_collection.manage_addECHO_locale(self,lang,title,label) |
|
|
Line 351 class ECHO_basis:
|
Line 390 class ECHO_basis:
|
js+="""addArea('%s', 'overview', %s, '%s', '%s');\n"""%(ob.getFullId(),ob.getCoordString(),ob.getType(),perm) |
js+="""addArea('%s', 'overview', %s, '%s', '%s');\n"""%(ob.getFullId(),ob.getCoordString(),ob.getType(),perm) |
return js |
return js |
|
|
def createMapHead(self): |
def createMapHead(self,mapColTypes=None): |
"""create javascript include and script tags for head""" |
"""create javascript include and script tags for head""" |
pt=zptFile(self, 'zpt/ECHO_content_map_frag_js') |
pt=zptFile(self, 'zpt/ECHO_content_map_frag_js') |
return pt() |
return pt(mapColTypes=mapColTypes) |
|
|
def createMapImg(self): |
def createMapImg(self): |
"""generate img-tag for map""" |
"""generate img-tag for map""" |
Line 924 def writeMetadata(url,metadict,project=N
|
Line 963 def writeMetadata(url,metadict,project=N
|
|
|
|
|
except: |
except: |
zLOG.LOG("ECHO writeMetadata",zLOG.ERROR,"XCannot open: "+url) |
logger("ECHO writeMetadata",logging.ERROR,"XCannot open: "+url) |
return (None,"XCannot open: "+url) |
return (None,"XCannot open: "+url) |
|
|
try: |
try: |
dom=xml.dom.minidom.parseString(geturl) |
dom=xml.dom.minidom.parseString(geturl) |
except: |
except: |
zLOG.LOG("ECHO writeMetadata",zLOG.ERROR,"Cannot parse: "+url+"<br>"+geturl) |
logger("ECHO writeMetadata",logging.ERROR,"Cannot parse: "+url+"<br>"+geturl) |
return (None,"Cannot parse: "+url+"<br>"+geturl) |
return (None,"Cannot parse: "+url+"<br>"+geturl) |
|
|
|
|
Line 1159 class MapArea(SimpleItem):
|
Line 1198 class MapArea(SimpleItem):
|
parent = self.aq_parent |
parent = self.aq_parent |
text = parent.getMapText() |
text = parent.getMapText() |
if text is not None: |
if text is not None: |
return text.document_src() |
#return text.document_src() |
|
return text() |
return "" |
return "" |
|
|
def getLabel(self): |
def getLabel(self): |
Line 1214 class MapText(Folder,ZopePageTemplate):
|
Line 1254 class MapText(Folder,ZopePageTemplate):
|
self.ZBindings_edit(self._default_bindings) |
self.ZBindings_edit(self._default_bindings) |
if text is None: |
if text is None: |
text = open(self._default_content_fn).read() |
text = open(self._default_content_fn).read() |
|
if content_type is None: |
|
content_type = self.content_type |
self.pt_edit(text, content_type) |
self.pt_edit(text, content_type) |
|
|
def createLocale(self): |
def createLocale(self): |