jemminger wrote:
> i've been mucking about trying different ways to customize my User
> class to inherit from TG_User but use emailAddress as the primary
> identifier. so far so good i think, but the problem i have now is that
> when i try to log in, tg is looking up the user based on userId, but
> i'm only passing in email and password.
>
> how can i override byUserId() to point to byEmailAddress() in my
> subclass?
I wanted to do the same thing. Here was my solution. Relevant part of
my custom User class:
# stuff below is to make Identity integration easier
@staticmethod
def byUserId(user_id):
"Returns a User object from a user_id."
return User.byEmail(user_id)
def _set_userId(self, user_id):
"Sets the user id (well, email)."
self.email = user_id
def _get_userId(self):
"Returns the email."
return self.email
# groups this user belongs to
groups= RelatedJoin( "Group")
I think I had to make a custom group too, as the mapping from user to
group wasn't automatic. In any case, here is my group class:
class Group(SQLObject):
class sqlmeta:
table="group_tbl"
groupId= UnicodeCol( length=16, alternateID=True )
displayName= UnicodeCol( length=255 )
created= DateTimeCol( default=datetime.now )
# collection of all users belonging to this group
users= RelatedJoin("User")
# collection of all permissions for this group
permissions= RelatedJoin( "TG_Permission", joinColumn="group_id",
intermediateTable="tg_group_permission",
otherColumn="permission_id" )
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---