2009/5/20 Filip Gruszczyński <grusz...@gmail.com>

>
> > I don't have major beefs with your solution, but I'll offer a few
> > alternatives that might accomplish the same thing, without creating
> > inheritance.  Inheritance feels a little heavy for what you're trying
> > to provide, which is basically just a common method to tie together
> > three other methods.  Seems like it might be more pythonic to do
> > simple duck typing, but that's just my two cents of course.
>
> What about having it like this:
>
> class Request:
>
>        @classmethod
>        def accept(Class, request, *args, **kwargs):
>                Class().serve(request, *args, **kwargs)
>
>        def serve(self, request, *args, **kwargs):
>                 self.prepare(request, *args, **kwargs)
>                if request.method == 'POST':
>                        value = self.servePost(request, *args, **kwargs)
>                        if value is not None:
>                                return value
>                else:
>                        value = self.serveGet(request, *args, **kwargs)
>                        if value is not None:
>                                return value
>                return self.serveBoth(request, *args, **kwargs)
>
>         def prepare(self, request, *args, **kwargs):
>                 pass
>
>        def servePost(self, request, *args, **kwargs):
>                 pass
>
>        def serveGet(self, request, *args, **kwargs):
>                 pass
>
>        def serveBoth(self, request, *args, **kwargs):
>                 pass
>
>
> I am most concerned with it being thread (and not only thread) safe.
> Your alternatives are cool, but I would like to get a solution as
> general as (in practical sense) possible.
>
> --
> Filip Gruszczyński
>
> >
>
Take a look at this:
http://code.djangoproject.com/ticket/6735#comment:37snippet which
actually does let you store state on the object.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to