--- ECHO_content/ECHO_collection.py 2007/02/20 15:55:21 1.285 +++ ECHO_content/ECHO_collection.py 2007/03/09 17:57:13 1.286 @@ -42,6 +42,7 @@ from Products.ZCatalog.CatalogPathAwaren from Products.ZCTextIndex.ZCTextIndex import manage_addLexicon import urllib +import urllib2 import cgi import smtplib import time @@ -74,8 +75,8 @@ try: except: print "no echo_language" class ECHO_language: - """ leere Klasse""" - pass + """ leere Klasse""" + pass from ECHO_movie import * import vlp_xmlhelpers #TODO: vlp elemente aus echo herausnehmen @@ -89,9 +90,9 @@ def logger(txt,method,txt2): logging.info(txt+ txt2) def normalizeCt(str): - """normalizes content_type""" - #str= str.replace(" ","_") - return str.replace("-"," ").lower() + """normalizes content_type""" + #str= str.replace(" ","_") + return str.replace("-"," ").lower() def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs=""): @@ -363,7 +364,7 @@ class ECHO_fullText(ZopePageTemplate,ECH def getPage(self,nr='1'): """get page n""" #return self().encode('latin-1','ignore') - try: + try: dom=xml.dom.minidom.parseString(self()) except: dom=xml.dom.minidom.parseString(self().encode('latin-1')) @@ -1330,7 +1331,7 @@ class ECHO_resource(CatalogAware,Folder, #caching if not hasattr(self,'_v_mapHash'): #noch keine cachevariable self._v_mapHash={} - + tmp=self._v_mapHash.get(ct,None) @@ -1519,7 +1520,7 @@ class ECHO_resource(CatalogAware,Folder, tags=self.findTagsFromMapping(normalizeCt(self.contentType)) self.referencetypes=tags[2] for referenceTypeF in self.referencetypes: - + if normalizeCt(referenceTypeF[1].title) == normalizeCt(referenceType.lower()): @@ -1771,8 +1772,8 @@ class ECHO_externalLink(Folder,ECHO_basi self.responsible=responsible coordsnew=[ string.split(x,",") for x in coords] self.coords=coordsnew - self.linkType = linkType # Linktypen 'otherPresentation','external' - + self.linkType = linkType # Linktypen 'otherPresentation','external' + def ECHO_externalLink_config(self): """Main configuration""" @@ -1793,20 +1794,32 @@ class ECHO_externalLink(Folder,ECHO_basi setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) self.link=link - self.linkType = linkType + self.linkType = linkType if RESPONSE is not None: RESPONSE.redirect('manage_main') - + def getLinkType(self): """ return linkType """ if hasattr(self,"linkType"): - return self.linkType - else : - return 'otherPresentation' + return self.linkType + else : + return 'otherPresentation' def setLinkType(self,type): """ set linkType """ self.linkType = type + + def checkLink(self): + """ returns tuple (isWorking,Error) """ + try: + urllib2.urlopen(self.link) + return (True, '') + except urllib2.HTTPError, e: + return (False, e.code) + except urllib2.URLError, e: + return (False, str(e.reason)) + except: + return (False, 'unknown Error') manage_options = ( @@ -1819,7 +1832,7 @@ class ECHO_externalLink(Folder,ECHO_basi """standard page""" return self.REQUEST.RESPONSE.redirect(self.link) - + def manage_addECHO_externalLinkForm(self): """Form for external Links""" @@ -2669,7 +2682,7 @@ class ECHO_collection(CatalogAware, Fold self.secondaryLinkTitle=secondaryLinkTitle self.secondaryLink=secondaryLink self.bgcolour=bgcolour - self.isVisible=isVisible + self.isVisible=isVisible manage_options = Folder.manage_options+ Cacheable.manage_options+( @@ -2725,7 +2738,7 @@ class ECHO_collection(CatalogAware, Fold self.isAlwaysClickable=isAlwaysClickable self.prefix=prefix[0:] self.suffix=suffix[0:] - self.setIsVisible(isVisible) + self.setIsVisible(isVisible) setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight)