I opted for not_anonymous predicate for one simple reason ... if user is logged in, tmpl_context will have a "user" attribute which will hold current user data. So, at template render time, it is possible to check presence of this attribute or use it to do a specific job.
about "identity" ... reading a little more in this section <http://turbogears.readthedocs.org/en/rtfd2.3.0b1/turbogears/authentication.html#how-it-works-in-turbogears> in TG documentation I found that identity is available in template context trough tg.identity and after doing some test I found that it is available trough tmpl_context.identity too. And if user is authenticated this identity dictionary will have a key named "user" which will contain current user data which I need to in some paces. to recap, identity can be accessed from: request.environ.get('repoze.who.identity') request.identity -- is a short cut for previous method tg.identity -- inside template context tmpl_context.identity Only now I'm starting to realize that predicates are used to secure access to controllers or views and not to control workflow. Thank you Chris for pointing me towards identity dictionary ... all I need to do now is to choose from where access it :) -- Petru On Sat Jan 10 2015 at 2:58:51 PM Christoph Zwerschke <[email protected]> wrote: > Am 09.01.2015 um 23:53 schrieb Petru Ciobanu: > > To achieve this I was thinking to combine some predicates in this way: > > | > > Any(not_anonymous(),Not(not_anonymous())) > > That gives a predicate that always returns True which is not really > useful ;-) > > What you should do is open the controller for everybody (i.e. don't add > a @require decorator) and then check in the controller or in the view > whether the user is authenticated or not. > > You could check this with a predicate, like this: > > tg.predicates.not_anonymous().is_met(request.environ) > > But in this case it's much easier to just check whether tg.identity is > set or not. You can either do this already in the controller method and > then pass only a limited amount of info if it's not set, or you can > check this in the view template and display a different amount of the > full info that has been passed by the controller. > > It's really straightforward. > > -- Chris > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/turbogears. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/d/optout.

