On Mar 7, 2011, at 9:23 AM, ron_m wrote:
> I am guessing some more because I didn't trace the code but I think auth.user 
> eventually gets set in login_bare without setting auth.user_id but then do 
> standalone apps actually login?
> I could only find 3 places where self.user_id is used in the class, the 2 
> places in the if else and as a test to see which of the nav bars (login or 
> logout) should be placed at the top of the page. I could not see anywhere 
> else that auth.user_id is set outside the class.

Good point.

I was wondering if auth.user_id ought to be set wherever auth.user is set, for 
consistency; I see about six places where that doesn't happen.

But how about this: make Auth.user_id a read-only property instead of a plain 
attribute? (Read-only just as a precaution; there's no good reason for someone 
to write it.)

Something like:

    def _get_user_id(self):
        "accessor for user_id"
        return self.user and self.user.id or None
    user_id = property(_get_user_id, doc="user.id or None")


This would be backward-compatible with the current logic, and make auth.user_id 
always identical to auth.user.id (whenever auth.user is defined) without having 
to catch every assignment of auth.user.

Work for you, Massimo?

Reply via email to