On 1/6/07, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
On 06-Jan-07, at 11:32 AM, chasfs wrote: > Any suggestions other than removing the login_required decorator and > doing the work in each view? use user_passes_test - this has an option for adding the return url
Unfortunately, that won't help with documentation; from the point of view of Python -- and remember that documentation is obtained by standard Python introspection -- the decorated function has been clobbered. The '_checklogin' function he's seeing is a function defined internally in user_passes_test (since login_required is just user_passes_test with an authentication check, you see this no matter which decorator you use). In theory, the documentation _could_ work because user_passes_test is smart enough to copy the original view's docstring and attach it to the decorated function, but the problem here is that the links to view documentation auto-generated in the admin concatenate the view's __module__ and __name__ attributes to get a view name, but both of those get clobbered by the decorator; __module__ becomes 'django.contrib.auth.decorators' (since that's the module the decorator lives in) and __name__ becomes '_checklogin' (since that's the name of the internal function returned from inside the decorator). Concatenating those gets the non-existent function name 'django.contrib.auth.decorators._checklogin', which is why he gets a 404 in the admin docs when trying to view it. What's needed to actually make this work is for user_passes_test to copy over __module__ and __name__ from the decorated function to its internal _checklogin function, in addition to __doc__. -- "May the forces of evil become confused on the way to your house." -- George Carlin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---