> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---