2009/5/20 Filip Gruszczyński <grusz...@gmail.com> > > > Take a look at this: > http://code.djangoproject.com/ticket/6735#comment:37 > > snippet which actually does let you store state on the object. > > The suggested solution is very cool, but I wonder, how to change > status code of such responses. status_code is a class attribute, so if > while serving a request I decide I need to change it's status, I will > have to change this value. > > But wait - if at some point I decide to for example turn the response > into redirect, I can just call: > self.status_code = 302 > and I won't actually change the class attribute, but only instance > attribute, right? So I can just subclass HttpResponse, add all stuff > (like having function forbid or redirect) and it should work? > > -- > Filip Gruszczyński > > > > The way python attributes work is that if something is a class attribute, but you assign to it on an instance the instance gets it's own version of this attribute which "shadows" the classes one. So if Django does something like: status = response.status_code it will just see the objects version, not it's classes.
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 -~----------~----~----~----~------~----~------~--~---