These should be equivalent, though technically
@auth.requires_membership('Admin') is equivalent to @auth.requires(lambda:
auth.has_membership(role='Admin')). Using the lambda prevents unnecessary
database hits checking for membership in cases where the controller file is
executed but the specific decorated function is not called.
Perhaps you can post a minimal app that reproduces the problem.
Anthony
On Sunday, February 10, 2013 11:40:45 PM UTC-5, 黄祥 wrote:
>
> hi,
>
> what is the difference within :
> @auth.requires_membership('Admin') and
> @auth.requires(auth.has_membership(role = 'Admin'))
> it seems there is some limitation in @auth.requires_membership('Admin')
>
> e.g.
> *case 1 :*
> *as expected result*
> *@auth.requires(auth.has_membership(role = 'Admin')) ### the difference*
> def __grid_0(flash, table):
> response.flash=T(flash)
> has_membership=auth.has_membership('Admin')
> grid=SQLFORM.smartgrid(table, onupdate=auth.archive,
> create=has_membership,
> editable=has_membership,
> deletable=has_membership)
> return dict(grid=grid)
>
> def manage_blog():
> return __grid_0(blog_manage_flash, blog_db)
>
> *unexpected result*
> *@auth.requires_membership('Admin') ### the difference*
> def __grid_0(flash, table):
> response.flash=T(flash)
> has_membership=auth.has_membership('Admin')
> grid=SQLFORM.smartgrid(table, onupdate=auth.archive,
> create=has_membership,
> editable=has_membership,
> deletable=has_membership)
> return dict(grid=grid)
>
> def manage_blog():
> return __grid_0(blog_manage_flash, blog_db)
>
> what i mean for unexpected result is, the user with the membership of
> group 'Admin' can not see the manage_blog page, when i modified it with
> *@auth.requires(auth.has_membership(role
> = 'Admin'))*, the user with the membership of group 'Admin' can see the
> manage_blog page.
>
> is there anyone know about it?
>
> thank you so much in advance
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.