This is not valid python syntax. Try:
submenu = []
response.menu = [(T('Manage'),URL(),URL(),submenu), ...]
if auth.has_membership('admin'): submenu += [
(T('Users'),URL('cms','users_manage')==URL(),URL('cms',
'users_manage'),[]),
(T('Groups'),URL('cms','groups_manage')==URL(),URL('cms',
'groups_manage'),[]),
(T('Exhibits'),URL('cms','exhibits_manage')==URL(),URL('cms',
'exhibits_manage'),[])]
if auth.has_membership('collection_admin'): submenu += [
(T('Display'),URL('cms','display_manage')==URL(),URL('cms',
'display_manage'),[]),
(T('Items'),URL('cms','items_manage')==URL(),URL('cms',
'items_manage'),[]),
(T('Categories'),URL('cms','categories_manage')==URL(),URL('cms',
'categories_manage'),[]),
(T('Tours'),URL('cms','tours_manage')==URL(),URL('cms',
'tours_manage'),[])]
if auth.has_membership('comment_moderator'): submenu += [
(T('Comments'),URL('cms','comments_manage')==URL(),URL('cms',
'comments_manage'),[]),
]
On Friday, 15 November 2013 19:06:25 UTC-6, Chris Hepworth wrote:
>
> I am new to web2py and have what may be a stupid question.
>
> In the application I am designing there are a number of different tables I
> have basic SQLforms to manage. I already have access control being enforced
> in the controller using the appropriate decorators, but I would like to
> further increase security by limiting which options are available in the
> menu. I was trying to use if statements as follows:
>
> (T('Manage'),URL(),URL(),[
> if auth.has_membership('admin'):
> (T('Users'),URL('cms','users_manage')==URL(),URL('cms',
> 'users_manage'),[]),
> (T('Groups'),URL('cms','groups_manage')==URL(),URL('cms',
> 'groups_manage'),[]),
> (T('Exhibits'),URL('cms','exhibits_manage')==URL(),URL('cms',
> 'exhibits_manage'),[]),
> if auth.has_membership('collection_admin'):
> (T('Display'),URL('cms','display_manage')==URL(),URL('cms',
> 'display_manage'),[]),
> (T('Items'),URL('cms','items_manage')==URL(),URL('cms',
> 'items_manage'),[]),
> (T('Categories'),URL('cms','categories_manage')==URL(),URL('cms',
> 'categories_manage'),[]),
> (T('Tours'),URL('cms','tours_manage')==URL(),URL('cms',
> 'tours_manage'),[]),
> if auth.has_membership('comment_moderator'):
> (T('Comments'),URL('cms','comments_manage')==URL(),URL('cms',
> 'comments_manage'),[]),
> ]),
>
> The error traceback indicates that the if statement is invalid, but I
> don't see why that would be. If someone with more experience could
> illuminate me, I would be much appreciated.
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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.