[web2py] Re: If logic in the menu.py model

2013-11-18 Thread Chris Hepworth
That worked perfectly! Thank you for the help, I guess my command of basic 
Python isn't nearly as good as I had thought...

On Saturday, November 16, 2013 2:05:40 AM UTC-7, Massimo Di Pierro wrote:

 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: If logic in the menu.py model

2013-11-18 Thread 黄祥
what is the URL() in second argument use for in this case?
URL('cms','users_manage')==URL()

i've checked the book for that but got no explaination about that :
No results for url()

thanks and best regards,
stifan

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: If logic in the menu.py model

2013-11-18 Thread Federico Ferraro
Comparison syntax...


2013/11/18 黄祥 steve.van.chris...@gmail.com

 what is the URL() in second argument use for in this case?
 URL('cms','users_manage')==URL()

 i've checked the book for that but got no explaination about that :
 No results for url()

 thanks and best regards,
 stifan

 --
 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 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
--
Federico Ferraro
Usuario Linux : 482533.
--

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: If logic in the menu.py model

2013-11-16 Thread Massimo Di Pierro
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.