Changeset 2932 in products
- Timestamp:
- Oct 26, 2010 5:35:28 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/browser/keywords.py
r2931 r2932 5 5 from zope.component import getUtility 6 6 from zope.component import queryAdapter 7 8 from Acquisition import aq_acquire 7 9 from Products.Five.browser import BrowserView 8 10 … … 42 44 # 2. timeout option added in python 2.6 (so acceptable only in plone4+) 43 45 try: 46 resp = urllib2.urlopen(self.context.absolute_url()) 44 47 try: 45 resp = urllib2.urlopen(self.context.absolute_url())46 48 html = resp.read() 47 49 finally: 48 if 'resp' in locals().keys(): 49 resp.close() 50 resp.close() 50 51 except (urllib2.URLError, urllib2.HTTPError), e: 51 52 # In case of exceed timeout period or other URL connection errors. 53 # Get nearest to context error_log object (stolen from Zope2/App/startup.py) 54 html = None 52 55 info = sys.exc_info() 53 elog = getToolByName(self.context, "error_log") 54 if elog: 56 try: 57 elog = aq_acquire(self.context, '__error_log__', containment=1) 58 except AttributeError: 59 pass 60 else: 55 61 error_url = elog.raising(info) 56 html = None57 62 else: 58 63 html = unicode(self.context()).encode(enc) … … 61 66 result = [] 62 67 if html is None: 63 sfx = error_url and ", details at %s." % error_url or "." 64 result.append("Problem with page retrieval" + sfx) 68 result.append("Problem with page retrieval.") 69 if error_url: 70 result.append("Details at %s." % error_url) 65 71 else: 66 72 page_text = transforms.convert("html_to_text", html).getData()
Note: See TracChangeset
for help on using the changeset viewer.