Could you do something like a wrapper object in your view before it
hits the context?  The wrapper below relies on a field list, but you
could easily have it inspect the Meta class on the model and build the
list.

class RedWrap(object):
        def __init__(self,restrict,obj,attrlist=[]):
            super(RedWrap,self).__init__()
            self.obj = obj
            self.restrict = restrict
            self.attrlist = attrlist

        def __getattr__(self,name):
            if not (name in self.attrlist and self.restrict):
                return getattr(self.obj,name)
            else:
                return "[REDACTED]"


def view_person(request,id):
   person = RedWrap(request.redact,Person.objects.get(id=id),
['redactedfield1','redactedfield2'])
   ...

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to