Re: User.get_profile is too NIH-unfriendly

2007-04-04 Thread Max Derkachev
I wrote a reply, but it seems that Google lost it. In short. We can not subclass User or provide custom User-like class, and use it without loosing functionality that depends on contrib.auth stuff. The profile thing is the only officially proposed method for extending the User model at this time.

Re: User.get_profile is too NIH-unfriendly

2007-04-04 Thread James Bennett
On 4/4/07, Max Derkachev <[EMAIL PROTECTED]> wrote: > That's not a problem. The API lookup can be easily emulated in custom > class. The problem is that it tries to load the profile from django's > internal models cache, and that can't be easily emulated. One needs to > cheat django the hard way f

Re: User.get_profile is too NIH-unfriendly

2007-04-04 Thread Max Derkachev
The code would be like So, the code would be something like def get_profile(self): """ Returns site-specific profile for this user. Raises SiteProfileNotAvailable if this site does not allow profiles. """ if not hasattr(self, '_profile_cache'):

Re: User.get_profile is too NIH-unfriendly

2007-04-04 Thread Max Derkachev
On Apr 4, 2:09 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 4/4/07, Max Derkachev <[EMAIL PROTECTED]> wrote: > > > Well, User do nothing with the profile other then simply loading it in > > get_profile. > > Except that 'get_profile' uses a Django database API lookup. Suppose > we remove th

Re: User.get_profile is too NIH-unfriendly

2007-04-04 Thread James Bennett
On 4/4/07, Max Derkachev <[EMAIL PROTECTED]> wrote: > Well, User do nothing with the profile other then simply loading it in > get_profile. Except that 'get_profile' uses a Django database API lookup. Suppose we remove that, though: 1. How do we know what sort of object the "profile" is? 2. How

Re: User.get_profile is too NIH-unfriendly

2007-04-04 Thread Max Derkachev
Hi James. > > Second, models.get_model(app_label, model_name) enforce that the > > profile object must be a Model subclass and should be in > > INSTALLED_APPS. > > I think this is worth living with -- the standard use case will be > that it's a Django model class, and if it's not it becomes a nig

Re: User.get_profile is too NIH-unfriendly

2007-04-03 Thread James Bennett
On 4/3/07, Max Derkachev <[EMAIL PROTECTED]> wrote: > 1. app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.') > 2. model = models.get_model(app_label, model_name) > > First, it does not behave properly if the settings.AUTH_PROFILE_MODULE > is something like 'path.to.app.models.Profile'.

User.get_profile is too NIH-unfriendly

2007-04-03 Thread Max Derkachev
Hi. The offending code is: 1. app_label, model_name = settings.AUTH_PROFILE_MODULE.split('.') 2. model = models.get_model(app_label, model_name) First, it does not behave properly if the settings.AUTH_PROFILE_MODULE is something like 'path.to.app.models.Profile'. Second, models.get_model(app_lab