def pdb_runcall(object, args, request):
    """If the request has the pdb_runcall key then we run the result
    of request traversal in the debugger.  Othwise, do it normally.

    A cookie for pdb_runcall may also be set or removed if the request
    has the toggle_runcall key."""
    response = request.response

    if 'toggle_runcall' in request and request.toggle_runcall:
        runcall_cookie = request.cookies.get('pdb_runcall', False)
        if runcall_cookie:
            response.expireCookie('pdb_runcall')
            return Publish.call_object(object, args, request)
        else:
            response.setCookie('pdb_runcall', 1)

    if 'set_runcall_ignore' in request:
        if request.set_runcall_ignore:
            for ignore in request.set_runcall_ignore:
                response.appendCookie('runcall_ignore', ignore)
        else:
            response.expireCookie('runcall_ignore')

    if 'pdb_runcall' in request:
        if request.pdb_runcall:
            ignores = request.get('runcall_ignore', [])
            if ignores:
                ignores = ignores.split(':')
            for ignore in ignores:
                obj = resolveDottedName(ignore)
                if obj.im_func is getattr(object, 'im_func', None):
                    break
            else:
                return pdb.runcall(object, *args)
    return Publish.call_object(object, args, request)
def pdb_runcall(object, args, request):
    """If the request has the pdb_runcall key then we run the result
    of request traversal in the debugger.  Othwise, do it normally.

    A cookie for pdb_runcall may also be set or removed if the request
    has the toggle_runcall key."""
    response = request.response

    if 'toggle_runcall' in request and request.toggle_runcall:
        runcall_cookie = request.cookies.get('pdb_runcall', False)
        if runcall_cookie:
            response.expireCookie('pdb_runcall')
            return Publish.call_object(object, args, request)
        else:
            response.setCookie('pdb_runcall', 1)

    if 'set_runcall_ignore' in request:
        if request.set_runcall_ignore:
            for ignore in request.set_runcall_ignore:
                response.appendCookie('runcall_ignore', ignore)
        else:
            response.expireCookie('runcall_ignore')

    if 'pdb_runcall' in request:
        if request.pdb_runcall:
            ignores = request.get('runcall_ignore', [])
            if ignores:
                ignores = ignores.split(':')
            for ignore in ignores:
                obj = resolveDottedName(ignore)
                if obj.im_func is getattr(object, 'im_func', None):
                    break
            else:
                return pdb.runcall(object, *args)
    return Publish.call_object(object, args, request)
Exemple #3
0
 def new_publish(request, module_name, after_list, debug=0):
     id = get_ident()
     Publish._requests[id] = request
     x = Publish.old_publish(request, module_name, after_list, debug)
     try:
         del Publish._requests[id]
     except KeyError:
         # Some people has reported that sometimes a KeyError exception is
         # raised in the previous line, I haven't been able to reproduce it.
         # This try/except clause seems to work. I'd prefer to understand
         # what is happening.
         LOG(PKG_NAME, PROBLEM,
             "The thread number %s doesn't have an associated request object." % id)
     return x