I'd like to write some code that modifies a page depending on whether the view that generated it requires login or not. Right now all such views are decorated with @login_required.
My initial thoughts on how to do this (coming from java) would be to slap an annotation on the views that are secure and have a middleware inspect the view object in process_view() to see if that annotation was there and modify the request accordingly. Then the base template would have a simple branch to check for that attribute (which is exposed via RequestContext and a contextprocessor if necessary) and render the appropriate text. However, decorators in python aren't at all similar to annotations and I'm not sure if it even makes sense to be able to ask a function object if it's been decorated (it doesn't really know since decorators just wrap functions). I could check to see if the function name is 'require_login' but that seems fragile and breaks if a function is decorated multiple times. Can anyone offer any advice on how to achieve my goal in a pythonic way? -- --Leo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

