Lennart Regebro wrote at 2005-7-13 12:47 +0200:
>Ever noticed how it's near impossible to figure out what actually
>causes an error when you run functional tests? Can you fix that too?
I solve this with a browser emulation that does not use HTTP for requests
but instead emulates "ZPublisher.Publish.publish" and therefore
can handle exceptions itself. It somehow looks like this:
def _internalRequest(self, path, query, method, headers, request_params,
'''perform a request against the internal *url*.'''
from Zope import zpublisher_exception_hook as err_hook
from Zope import zpublisher_validated_hook as validated_hook
# Note: we should use the checkpoint feature, new in ZODB 3.3
# Unfortunately, we still use ZODB 3.2...
# Without this feature, we cannot reliably undo the effects
# of failed requests (we try with subtransactions)
request = self._makeRequest(path, query, method, headers, request_params)
zope_response = request.response
object = request.traverse(request['PATH_INFO'].strip(),
result=mapply(object, request.args, request,
if result is not zope_response: zope_response.setBody(result)
# Probably, we need special treatment for 'raise redirect'
if not catch_exc or err_hook is None: raise
# we learned from Malcolm that 'err_hook' always raises an exception
zope_response = err_hook(request['PARENTS'], *exc_info())
# Note: we do not handle "Retry" (as it is very unlikely)
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists -