none whatsoever (in a normal environment). 
It's just that models are executed at every request, while controller gets 
called only when you hit the page.
Usually to avoid to copy over and over the same menu items in multiple 
places, you put the code in models.
>From a theoric standpoint, having menu defined in every controller OR have 
the menu just in one model is equal in terms of performance. 
What's silly is having BOTH a model defining a menu AND every controller 
redefining that, because the time spent on defining the menu in the model 
is basically wasted.
You need to "balance" code readability vs performance ....  but defining a 
list doesn't take that much time.


On Thursday, February 14, 2013 9:58:38 PM UTC+1, 黄祥 wrote:
>
> hi,
>
> is there any performance impact when put menu in controller? i know i can 
> modify the menu.py or create the new file menu_custom.py in models but i 
> don't want to change default web2py file scaffolding generated as much as 
> possible.
>
> for example
> *controllers/default.py*
> *
> *
> # -*- coding: utf-8 -*-
>
> # menu
> response.menu = [
>     (T('Home'), False, URL('default', 'index'), []),
>     (T('Room'), False, URL('default', 'room'), []),
>     (T('Guest'), False, URL('default', 'guest'), []),
>     (T('Booking'), False, URL('default', 'booking'), []),
>     (T('Check In'), False, URL('default', 'check_in'), []),
>     (T('Check Out'), False, URL('default', 'check_out'), []),
>     (T('Repairing'), False, URL('default', 'repairing'), []),
>     (T('Cleaning'), False, URL('default', 'cleaning'), []),
> ]
>
> if auth.user and auth.has_membership(role='Manager'):
>     response.menu.append((T('Branch'), False, URL('default', 'branch')))
>     response.menu.append((T('Company'), False, URL('default', 'company')))
>
> DEVELOPMENT_MENU = False
>
> thousand thanks 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.


Reply via email to