On Tue, Mar 9, 2010 at 8:47 AM, Shawn Milochik <sh...@milochik.com> wrote: > I wonder if this is something that might end up in Django as a built-in > feature at some point. It comes up regularly on this list.
Were I to sit here all morning doing nothing but typing, I wouldn't be able to say "no" enough times to that. If you need access to the user somewhere, write a function or method which takes the user as an argument, and have your view call that function or method, passing the user. This is approximately eighty billion times simpler than coming up with threadlocal hacks to try to create a magic global user variable, results in cleaner, easier-to-understand code, reduces the likelihood of difficult-to-track bugs in the code and, best of all, is a perfectly obvious way to accomplish the task. And, in all seriousness, when even the page you've linked to says that it's not a good solution and should be avoided, why do you insist on continuing to use it? One begins to suspect that some malevolent entity has been going around magically crippling the fingers of programmers in such a way that they're no longer capable of writing a method signature including an argument named "user". -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.