so lets say i am updating a users authentication level i am trying to
do this

u = DBSession.query(User).filter_by(user_name=session.get
('old_username', None)).one()
                u.user_name = str(kw['username'])
                u.display_name = str(cgi.escape(kw['display']))
                u.email_address = str(cgi.escape(kw['email']))
                u.groups[0].group_id = str(cgi.escape(kw['group']))


but it throws the error IntegrityError: (IntegrityError) PRIMARY KEY
must be unique u'UPDATE tg_group SET group_id=? WHERE
tg_group.group_id = ?' ['3', 5]. What have i missed?

On Nov 22, 4:22 pm, Jasper <[email protected]> wrote:
> The User has a groups list as attribute. Group.group_name will give
> you the group name.
>
> ex:
> DBSession.query(User).first().groups[0].group_name
> (assuming that the first user is member of at least one group ;) )
>
> Kind regards,
>     Jasper
>
> On Nov 22, 2:21 pm, adam <[email protected]> wrote:
>
>
>
> > Hello,
>
> > I am using the TG2 authentication method and i need to get the name of
> > the group a user belongs too. How do i go about searching the
> > tg_user_group table for the group_id for the mathcing user_id and then
> > search the tg_group table for the name?

--

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?hl=.


Reply via email to