On Thu, Mar 19, 2009 at 9:22 AM, Thomas Guettler <h...@tbz-pariv.de> wrote:
> > Hi, > > I know that you can pass the request object to form like this: > > class MyForm(forms.Form): > def __init__(self, request, *args, **kwargs): > self.request=request > forms.Form.__init__(self, *args, **kwargs) > > Somehow I am tired of rewriting this. Why not store the request > object (in a thread safe way) on module level? > > I recall that someone said this is not good. What are the pro and > contra arguments? > > Most of the time I need request.user to hide some input fields. > > Thomas > > -- > Thomas Guettler, http://www.thomas-guettler.de/ > E-Mail <http://www.thomas-guettler.de/%0AE-Mail>: guettli (*) > thomas-guettler + de > > > > The biggest con is encourages bad design practices, the way Python works is you have a global and local scope, if you want something in your local scope you pass it to it. If you really want to have the request object stored you can write a custom middleware to do it, but I woulldn't. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---