Back to index

plone3  3.1.7
Functions
plone.app.linkintegrity.monkey Namespace Reference

Functions

def zpublisher_exception_hook_wrapper
def proxy_get_module_info
def installExceptionHook
def retry

Function Documentation

Definition at line 42 of file monkey.py.

00042 
00043 def installExceptionHook():
00044     import ZPublisher.Publish
00045     ZPublisher.Publish.get_module_info = proxy_get_module_info
00046 

Here is the caller graph for this function:

Definition at line 35 of file monkey.py.

00035 
00036 def proxy_get_module_info(*args, **kwargs):
00037     results = list(get_module_info(*args, **kwargs))
00038     if results[5] is zpublisher_exception_hook:
00039         results[5] = zpublisher_exception_hook_wrapper
00040     return tuple(results)
00041 

re-initialize a response object to be used in a retry attempt 

Definition at line 47 of file monkey.py.

00047 
00048 def retry(self):
00049     """ re-initialize a response object to be used in a retry attempt """
00050     # this implementation changes the original one so that the response
00051     # instance is reused instead of replaced with a new one (after a Retry
00052     # exception was raised);  this fixes a bug in zopedoctests' http()
00053     # function (Testing/ZopeTestCase/zopedoctest/functional.py:113);
00054     # the doctest code assumes that the HTTPResponse instance passed to
00055     # publish_module() (line 177) is used to handle to complete request, so
00056     # it can be used to get the status, headers etc later on (lines 183-186);
00057     # normally this is okay, but raising a Retry will create a new response
00058     # instance, which will then hold that data (relevant for evaluating the
00059     # doctest) while the original (passed in) instance is still empty...
00060     #
00061     # so to fix this (quickly) retry() now cleans up and returns itself:
00062     self.__init__(stdout=self.stdout, stderr=self.stderr)
00063     return self

def plone.app.linkintegrity.monkey.zpublisher_exception_hook_wrapper (   published,
  REQUEST,
  t,
  v,
  traceback 
)
wrapper around the zope2 zpublisher's error hook 

Definition at line 9 of file monkey.py.

00009 
00010 def zpublisher_exception_hook_wrapper(published, REQUEST, t, v, traceback):
00011     """ wrapper around the zope2 zpublisher's error hook """
00012     try:
00013         # if we got a retry exception, we just propagate it instead of
00014         # trying to log it (like FiveException does)
00015         if t is Retry:
00016             v.reraise()
00017         # first we try to find a view/adapter for the current exception and
00018         # let the original function try to handle the exception if we can't
00019         # find one...
00020         view = queryMultiAdapter((v, REQUEST), name='index.html', default=None)
00021         if view is None:
00022             zpublisher_exception_hook(published, REQUEST, t, v, traceback)
00023         else:
00024             # otherwise render the view and raise the rendered string like
00025             # raise_standardErrorMessage does...
00026             view = view.__of__(published)
00027             message = view()
00028             if isinstance(message, unicode):
00029                 message = message.encode('utf-8')
00030             raise t, message, traceback
00031     finally:
00032         traceback = None
00033