On Nov 8, 2007 6:38 AM, Alexander Solovyov <[EMAIL PROTECTED]> wrote:
> - (main trouble) if you have absolutely different applications, which
> use profile for their
>   own purposes, you need to merge their Profile models - trouble is in
> the updating of
>   this thing (f.e., you have forum, created by someone and integrated
> in your project, and
>   you definitely want to have updates).

On this particular point, from the perspective of the reusable
applications themselves, you don't need to worry about merging profile
models, even if you are potentially working with many of them in your
overall project. Going with the forum example, if your forum
application defines its own profile Model which addresses all of its
specific needs, it doesn't benefit it in any way if it has access to
some kind of merged profile instead - it does, however, introduce the
potential for conflicts.

Personally, I never rely on the AUTH_PROFILE_MODEL setting and the
User.get_profile method in reusable applications, I only use those in
my main project. It's not a lot of work to add a method to your
application's profile Manager to load and cache a user's
application-specific profile in a manner similar to User.get_profile.
Since I'm actually working on a reusable forum application at the
moment, here's an example of what I mean:

class ForumProfileManager(models.Manager):
    def get_for_user(self, user):
        """
        Returns the ForumProfile for the given user, creating it first if
        necessary and caching it the first time it is looked up.
        """
        if not hasattr(user, '_forum_profile_cache'):
            profile, created = self.get_or_create(user=user)
            user._forum_profile_cache = profile
        return user._forum_profile_cache

Jonathan.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to