On Jan 20, 11:16 am, Antonio Beamud <[email protected]> wrote:
> What's the better way to check permissions, groups or auth inside a mako
> template, for example, to show only part of the web page based on the
> user accessing it.
> Now, I'm using something like this:
>
>   class MyController(BaseController):
>      def index(self):
>         c.is_manager = in_group('manager').is_met(request.environ)
>         return render('/index.mako')
>
> In the index.mako template:
>
> ...
> %if c.is_manager:
> <p>Hello manager</p>

I'm doing just what you did in my templates, although I use
"c.is_manager = is_met(has_permission('edit-something'))" . You could
also make is_met and repoze.what.predicates default imports in the
mako templates (in config/environment.py) and use them directly in the
template, but that seems like too much logic in the template for my
liking.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to