Back to index

plone3  3.1.7
standard_error_message.py
Go to the documentation of this file.
00001 ## Script (Python) "standard_error_message"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=**kwargs
00008 ##title=Dispatches to relevant error view
00009 ##
00010 
00011 ## by default we handle everything in 1 PageTemplate.
00012 #  you could easily check for the error_type and
00013 #  dispatch to an appropriate PageTemplate.
00014 
00015 # Check if the object is traversable, if not it might be a view, get its parent
00016 # because we need to render the error on an actual content object
00017 from AccessControl import Unauthorized
00018 try:
00019     while not hasattr(context.aq_explicit, 'restrictedTraverse'):
00020         context = context.aq_parent
00021 except (Unauthorized, AttributeError):
00022     context = context.portal_url.getPortalObject()
00023 
00024 error_type=kwargs.get('error_type', None)
00025 error_message=kwargs.get('error_message', None)
00026 error_log_url=kwargs.get('error_log_url', None)
00027 error_tb=kwargs.get('error_tb', None)
00028 error_traceback=kwargs.get('error_traceback', None)
00029 error_value=kwargs.get('error_value', None)
00030 
00031 if error_log_url:
00032     error_log_id=error_log_url.split('?id=')[1]
00033 else:
00034     error_log_id=None
00035 
00036 
00037 no_actions = {'folder':[], 'user':[], 'global':[], 'workflow':[]}
00038 error_page=context.default_error_message(error_type=error_type,
00039                                          error_message=error_message,
00040                                          error_tb=error_tb,
00041                                          error_value=error_value,
00042                                          error_log_url=error_log_url,
00043                                          error_log_id=error_log_id,
00044                                          no_portlets=True,
00045                                          actions=no_actions)
00046 
00047 return error_page