I'm coming to Django from the Java Spring MVC world, and over in those
remote lands we have something called a "Service" layer.

The service layer is responsible for doing all the business logic that
your views might otherwise do.  For example, you might have something
like:

        class UserService:
          def create_user(self,...)
          def create_friendship(self,user_a, user_b)

or maybe:

        class InvitationService:
          def send_email_invitation(self,...)
          def redeem_invitation(self,invitation)

These services would be instantiated as singletons which would then be
used by higher-up layers like the views. They would typically be re-
used between different views (eg. iPhone, desktop, and REST views
might all use the same service).

Looking at Django, I don't see an obvious place to put these sorts of
common business-logic methods.  They don't really belong in the views
since you don't want to have to reimplement them every time you add a
new platform.  But they also don't belong in the models, since you
might not want to tie your models to presentation-specifics such as
which email template to use.[1]

I'd like to do things the "Django way", so I thought I'd put the
question out to the community.  Where would be the best places to put
business logic like this?

Cheers,
Mike


[1] In addition, there might not be an obvious model for a particular
kind of service.  For example, what model would you use for a
FacebookService, if you need to integrate with the facebook platform?
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to