I was wondering: have you considered using some callable objects to
serve requests in views.py instead of functions?
I have recently created a class:
class RequestService:
def __call__(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)
When I need another view, I inherit from it and create an instance,
that is used instead of a function. I decided to use it, because my
views functions began to grow big and I wanted to divide them into
smaller chunks, and yet keep them logically connected.
What do you think about using this kind of solution? Have anyone tried it?
--
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
-~----------~----~----~----~------~----~------~--~---