Hi folks,what do you think about deprecating AUTH_PROFILE_MODULE and .get_profile() or removing the suggestion to use it from the docs in 1.4 release?There are broader issues with extending User model but I think this one can be handled separately.
Completely agreed. get_profile may not be ideal, but it's better than
providing nothing, and cleaning up get_profile will be a logical
extension of any good auth.User refactor.
Yours,
Russ Magee %-)
Deprecating get_profile() is pretty low on my priority list, but I'm a
bit confused by these two comments. What exactly does get_profile()
offer that needs to be "replaced" or is actually "better than providing
nothing"? Or, more specifically, better than recommending a
OneToOneField and the usual ORM accessor (even leaving aside the
multiple-profiles case)? In every way that I can see, it is worse than
that: it's a special case, requires additional cognitive overhead to
learn, more characters to type, more runtime processing, more code in
Django to maintain, and adds zero value.
The only possible argument for it I can see is that it provides a
standardized way for reusable apps to get at a project's user profile
model. But given that no assumptions can be made about what is on the
profile model, the range of useful uses for that is pretty much limited
to one case: providing some pre-built URLs etc for creation and editing
of profiles; i.e. django-profiles. And even that case gains nothing from
AUTH_PROFILE_MODULE being a built-in feature of Django as opposed to an
external setting documented by django-profiles itself.
I don't mind leaving get_profile() around, I guess, but IMO the best
argument that can be made for that is "it's useless but mostly harmless,
and it's not worth making people change their code to remove it." I'll
continue to recommend in IRC and elsewhere that people avoid using it.
Carl
Given a blank slate, what would Auth look like these days? And can we
work towards that?
Now, why you gotta get all constructive and forward-thinking and stuff? ;-)
Here's my list of core ideal-contrib.auth desiderata that I keep seeing
crop up in related threads:
1. A specification of the minimal useful interface for a User (perhaps
in the form of an abstract base model?)
2. A way to provide your own User class that extends the minimal spec,
in a single table (i.e. MTI need not apply).
3. A way for reusable apps to access and point foreign keys at the User
model (solutions that involve magically transporting models into other
modules need not apply - Django's been there, not going back).
4. A migration path that meets our backwards-compatibility standards.
Abstract base models already can handle 1 & 2, but if we take that
approach we still lack solid proposals for 3 & 4. And of course there
are many questions left untouched here (groups? permissions?), but these
are the core elements that I don't think I've heard much, if any,
disagreement on. I'd be interested to know if anyone sees a problem with
any of the above, or what people would add as core requirements.
Carl
> On 05/02/2011 11:38 AM, Jeremy Dunck wrote:
>> Given a blank slate, what would Auth look like these days? And can we
>> work towards that?
>
> Now, why you gotta get all constructive and forward-thinking and stuff? ;-)
>
> Here's my list of core ideal-contrib.auth desiderata that I keep seeing
> crop up in related threads:
>
> 1. A specification of the minimal useful interface for a User (perhaps
> in the form of an abstract base model?)
>
> 2. A way to provide your own User class that extends the minimal spec,
> in a single table (i.e. MTI need not apply).
>
> 3. A way for reusable apps to access and point foreign keys at the User
> model (solutions that involve magically transporting models into other
> modules need not apply - Django's been there, not going back).
As I've said before in person and on IRC, 2. and 3. will most likely be
possible with the app-loading branch. It introduces a notion of an app
class that would (among other things) allow to override the default auth
app by mimicking its API.
This is done by simply telling the app cache to consider a different app
as the app with the "auth" app label. E.g.:
$ cat myapp/models.py
from django.db import models
from django.contrib.auth.models import BaseUser # abstract base user
class User(BaseUser):
middle_name = models.TextField()
class Meta:
verbose_name = "My user"
$ cat myapp/app.py
from django import apps
class MyAuthApp(apps.App):
class Meta:
label = 'auth'
db_prefix = 'auth'
Then, in good tradition of duck typing, we use models.ForeignKey('auth.User')
to point to that custom user class, forcing the app cache to return the
myapp.models.User class.
> 4. A migration path that meets our backwards-compatibility standards.
As far as I understand there is little effort needed to split the User
model in an abstract base class and a concrete implementation that is
similar to the current class. Whether this needs some kind of migration
path is a different story.
Jannis
Certainly worth stating, but I don't think it's a major technical
challenge. An abstract base class approach should allow for the
concrete class to define the primary key type that is in use.
Yours,
Russ Magee %-)
"Better than nothing" was perhaps a bad choice of phrase on my part.
My point is that it does serve a purpose, however tangential -- it
provides an API hook that we can point at when someone says "How do I
put custom data on my User object". For me, when combined with the
fact that it's not hurting anyone to keep it around, this tangential
documentation benefit is the reason to keep it around until we "fix"
User -- even if we de-emphasise its use.
Yours,
Russ Magee %-)
1. A specification of the minimal useful interface for a User (perhapsin the form of an abstract base model?)
4. A migration path that meets our backwards-compatibility standards.
I looked into this today with 1.5 hitting and working on a project and this seemed relevant.On Monday, 2 May 2011 19:22:53 UTC+2, Carl Meyer wrote:1. A specification of the minimal useful interface for a User (perhapsin the form of an abstract base model?)
A User should not require a username. Usernames are a hideous remnant that are impossible to justify on consumer facing websites. Authentication on e-mail should be built-in if not the default.
4. A migration path that meets our backwards-compatibility standards.
I saw the configurable User model that just landed in 1.5 but for a non-library developer this is not very useful. It looks like a very large amount of code for a rather small function.
Furthermore: “If you intend to set AUTH_USER_MODEL, you should set it before running manage.py syncdb for the first time.” is somewhat prohibitive to existing projects. “you may need to look into using a migration tool like South to ease the transition.” is not really a solution unless it is obvious what changes should be made.
Also I don't understand: “This example illustrates how most of the components work together, but is not intended to be copied directly into projects for production use.” Code that is ready for production is the point of the documentation for me. If this isn't, I think it's a documentation bug.
--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
I'd be interested in actually doing this if folks on the list think it's a good idea.
I actually strongly disagree: I think Django *should* ship an
"authenticate-using-email" system.
I can't promise it'd go in -- I'm not going to
overrule a -1 from Florian by fiat -- but I think having a concrete
patch on the table will make it easier to make a decision.