On Sun, Aug 2, 2009 at 10:26 PM, Torsten
Bronger<bron...@physik.rwth-aachen.de> wrote:
>
> Hallöchen!
>
> My first Django project was a single application.  Probably most of
> you started this way, with only some other applications shipped with
> Django installed on the same site, too.
>
> However, I now prepare my second Django application which will be
> used together with the first one.  For me, this is no problem.  But
> I wonder how to write an application which can be easily integrated
> by others into their eco system.
>
> For example, get_profile() can only be connected with one model per
> site.  But every application may have its own UserDetails, so
> get_profile must actually be considered harmful, unless you know for
> sure that your application will never be used somewhere else.

Then don't use get_profile(). A User profile is, by definition (and
implementation) unique for a given user. If you don't have a unique
class or a unique profile, then you don't have a User Profile - you
have a model with a foreign key on User.

And that's fine. my_user.get_profile() is, at best, a convenience -
and not really a big one, either. Beyond the caching benefits (which
you can get through other channels if you really need them), it isn't
really any better than AppProfile.objects.get(user=my_user).

> http://code.djangoproject.com/ticket/3011 has the same problem,
> namely that only one application can extend the global
> datastructures.

#3011 is a separate issue to this, and one that I can sympathize with
(or at least, one that I would like to stop being a FAQ). Even if
#3011 is fixed, I would imagine that individual apps would continue to
have tables that contain app-specific profile data.

> I think that patching an application so that it doesn't login
> handling anymore (because another app does already) is okay, but for
> example substituting all get_profile calls is actually unnecessary.
> What do you think?

You shouldn't need to patch an application so that it does (or
doesn't) do login handling. You should have an application that
handles logins, and 2+ separate applications that are appropriately
decorated to ensure that users are logged in. This is the essence of
re-usable applications. If you have built an application that does
authentication/login _and_ something else, then your first port of
call is to separate this into two applications.

Yours,
Russ Magee %-)

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