The subject of the post versus the question posed within appear to be
different.  If you are truly talking about protecting a controller or
action, then, you would need to look at root.py on a quickstarted
project which shows you how a manager or editor can be handed limited
access to an action within a controller:

    @expose('tg201.templates.index')
    @require(predicates.has_permission('manage', msg=l_('Only for
managers')))
    def manage_permission_only(self, **kw):
        """Illustrate how a page for managers only works."""
        return dict(page='managers stuff')

    @expose('tg201.templates.index')
    @require(predicates.is_user('editor', msg=l_('Only for the
editor')))
    def editor_user_only(self, **kw):
        """Illustrate how a page exclusive for the editor works."""
        return dict(page='editor stuff')

Likewise, if you wanted to protect an entire controller for a specific
user:

class TestController(BaseController):
    allow_only = predicates.is_user('specificusername', msg="only
specificusername can log in here")

or that they authenticated:

class TestController(BaseController):
    allow_only = authorize.not_anonymous()

or that they are in the manage group:

class TestController(BaseController):
    allow_only = predicates.has_permission('manage', msg=l_('Only for
managers'))

If you want to access the repoze information within your template:

<py:if test="request.identity!=None">
Logged in as: <div py:content="request.identity['repoze.who.userid']"
py:strip=""/>
</py:if>

I'm reasonably sure you can access the predicates within the
template.  I've not dug deep enough into the code for that yet.

On Jun 30, 10:05 am, Kirk Strauser <[email protected]> wrote:
> I'm building a navigation system and only want to show actions that a user is
> authorized to access.  I've been digging around for that documentation but
> can't seem to find it and would appreciate a pointer.
>
> BTW, does such a navigation system already exist?  Surely so; I'm confident 
> I'm
> not the first person wanting to do this. :-)
> --
> Kirk Strauser
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to