I attempted to simplify creation of the response.menu list of tuples by the following function:
def menu_item(menu_item_text, url, sub_menu=None, ignore=False): # First element of tuple is the text of the meny item. retval = list(menu_item_text) # Second element of the tuple indicates if this menu item is the # current active one. retval.append(url == URL()) # Third element is the link to follow when this item is selected. retval.append(url) # The fourth item is an optional sub_menu. if sub_menu: retval.append(sub_menu) else: retval.append([]) retval.append(ignore) return retval but when using it like so: def public_menu(): response.menu += [ menu_item('How it Works', URL('default', 'how_it_works')), menu_item('Testimonials', URL('default', 'testimonials')), menu_item('Sign up Now!', URL('default', 'register')), menu_item('Login' , URL('default', 'login')), ] if auth.is_logged_in(): logged_in_menu() else: public_menu() I get the error: 127.0.0.1.2017-01-08.19-46-22.ca7178e4-a2b2-48f7-8463-81d2c8f70f27 <type 'exceptions.ValueError'> need more than 1 value to unpack Version web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. Traceback (most recent call last): File "/home/schemelab/domains/org/metaperl/web2py/web2py/gluon/restricted.py", line 227, in restricted exec ccode in environment File "/home/schemelab/domains/org/metaperl/web2py/web2py/applications/refbank/views/default/index.html", line 59, in <module> File "/home/schemelab/domains/org/metaperl/web2py/web2py/gluon/globals.py", line 430, in write self.body.write(xmlescape(data)) File "/home/schemelab/domains/org/metaperl/web2py/web2py/gluon/html.py", line 131, in xmlescape return data.xml() File "/home/schemelab/domains/org/metaperl/web2py/web2py/gluon/html.py", line 2580, in xml return self.serialize(self.data, 0).xml() File "/home/schemelab/domains/org/metaperl/web2py/web2py/gluon/html.py", line 2545, in serialize li.append(self.serialize(item[3], level + 1)) File "/home/schemelab/domains/org/metaperl/web2py/web2py/gluon/html.py", line 2525, in serialize (name, active, link) = item[:3] ValueError: need more than 1 value to unpack -- 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/d/optout.