Django 1.3 Error Report Deletes Confidential Information

I know that django 1.4 has the functionality to remove sensitive information in an error report. I am using django 1.3 and python 2.4. I want to know https://docs.djangoproject.com/en/dev/howto/error-reporting/#filtering-error-report ported back to django 1.3 and python 2.4.I tried without success. help

0
source share
1 answer

I would just copy decor_information decorator to the local decorators.py file and use it.

import functools


def sensitive_variables(*variables):
 """
 Indicates which variables used in the decorated function are sensitive, so
 that those variables can later be treated in a special way, for example
 by hiding them when logging unhandled exceptions.

 Two forms are accepted:

* with specified variable names:

    @sensitive_variables('user', 'password', 'credit_card')
    def my_function(user):
        password = user.pass_word
        credit_card = user.credit_card_number
        ...

* without any specified variable names, in which case it is assumed that
  all variables are considered sensitive:

    @sensitive_variables()
    def my_function()
        ...
"""
 def decorator(func):
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        if variables:
            wrapper.sensitive_variables = variables
        else:
            wrapper.sensitive_variables = '__ALL__'
        return func(*args, **kwargs)
    return wrapper
 return decorator

using:

@sensitive_variables('user', 'pw', 'cc')
def my_view(request):
  pass

You will need functools.py, which by default will not ship with python2.4 (I think). You may need to include this file separately.

0

All Articles