Ejemplo n.º 1
0
def middleware_hooks(module, objname):
    try:
        # wrap middleware callables we want to wrap
        cls = getattr(module, objname, None)
        if not cls:
            return
        for method in ['process_request',
                       'process_view',
                       'process_response',
                       'process_template_response',
                       'process_exception']:
            fn = getattr(cls, method, None)
            if not fn:
                continue
            profile_name = '%s.%s.%s' % (module.__name__, objname, method)
            setattr(cls, method,
                    oboe.profile_function(profile_name)(fn))
    except Exception, e:
        print >> sys.stderr, "Oboe error:", str(e)
import oboe
from ZPublisher.BaseRequest import BaseRequest

wrapper = oboe.profile_function('zope_traverse')
BaseRequest.orig_traverse = BaseRequest.traverse
BaseRequest.traverse = wrapper(BaseRequest.orig_traverse)
import oboe
from ZPublisher.BaseRequest import BaseRequest


wrapper = oboe.profile_function('zope_traverse')
BaseRequest.orig_traverse = BaseRequest.traverse
BaseRequest.traverse = wrapper(BaseRequest.orig_traverse)
import oboe
from plone.app.viewletmanager.manager import OrderedViewletManager


def extract_name(func, f_args, f_kwargs, res):
    kv = {'Name': f_args[0].__name__}
    return kv


OrderedViewletManager.orig_render = OrderedViewletManager.render
vm_wrapper = oboe.profile_function('plone_viewletman', callback=extract_name)
OrderedViewletManager.render = vm_wrapper(OrderedViewletManager.orig_render)