I could not actually get user=identity.user to work :(
Two options for getting the user; is one better than the other?
1)
uid=request.identity['repoze.who.userid']
user=User.by_user_name(uid)
2)
user2=request.identity['user']
These both get the same user object in my tests. Are they both
correct to use, or is option number 2 an undocumented feature that may
go away in a future TG version?
El Tea
On Jul 21, 3:50 pm, percious <[email protected]> wrote:
> you can get the current logged in identity by grabbing it from the
> environ:
>
> identity = request.environ.get('repoze.who.identity')
> user = identity.user
> group_names = identity.groups
>
> Lots of folks do something like this in their __call__ method of their
> BaseController:
>
> tmpl_context.identity = request.environ.get('repoze.who.identity')
>
> See docs
> here:http://www.turbogears.org/2.0/docs/main/Auth/Customization.html#enabl...
>
> On Jul 21, 1:29 pm, El Tea <[email protected]> wrote:
>
> > More searching as per the post on the bottom of this page
> > (http://www.turbogears.org/2.0/docs/main/Auth/Authentication.html) has
> > led me to believe the solutions are in tg.identity, but I don't know
> > where the documentation is.
>
> > El Tea
>
> > On Jul 21, 1:42 pm, El Tea <[email protected]> wrote:
>
> > > I have a pretty good grip on predicates. What I am not seeing in the
> > > TG documentation is how to find user information for use in the
> > > controllers and templates. What I want to do:
>
> > > a) Get the object for the current user.
> > > b) Determine, in a template, if the current user's group is 'manager'
> > > so I can render the page differently.
>
> > > My apologies if this is an easy one; I've been in the docs for an hour
> > > and all I can find info on is authorization to protect areas of the
> > > site. If you have a handy link with examples, I'd be happy to take
> > > that.
--~--~---------~--~----~------------~-------~--~----~
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=en
-~----------~----~----~----~------~----~------~--~---