Sorry I didn't see this sooner.
I think all your menu items will want that empty list, and I see some do
not.
Also I am confused about how a menu script could cause a dal to raise an
exception. Maybe somebody with a better knowledge of the internals will
chime in here.
On Wednesday, April 25, 2012 9:17:46 AM UTC-4, Omi Chiba wrote:
>
> Thanks again ! I came back from vacation and tried the code but I got
> different error...
>
> File "C:\web2py\gluon\dal.py", line 1386, in log_execute
> ret = self.cursor.execute(*a, **b)
> ProgrammingError: The cursor's connection has been closed.
>
>
>
> sub_menu = [('Admin', False, URL('admin'), []), ] # Added empty list
>
> response.menu = [('Home', False, URL('home','default','index'), []),
> (SPAN('Price List',_style='color:yellow'), True,
> URL('pricelist','default','index'),
> [('Guideline', False, URL('pricelist','default','guideline')),
> ('Multiplier Tables', False,
> URL('pricelist','default','multitable')),
> ('Cut Charge Tables', False, URL('pricelist','default','cuttable')),
> (sub_menu),
> ])]
>
>
>
> On Sunday, April 15, 2012 9:52:01 PM UTC-5, Cliff wrote:
>>
>> Omi,
>>
>> Sorry, my bad. Been away.
>>
>> Should be:
>> sub_menu = [('Admin', False, URL('admin'), []), ] # Added empty list
>>
>> On Thursday, April 12, 2012 9:43:39 AM UTC-4, Omi Chiba wrote:
>>>
>>> Cliff,
>>>
>>> Thank you for sharing code but now I got a different error. Maybe it
>>> cannot understand sub_menu contains three parameters..
>>>
>>> Traceback (most recent call last):
>>> File "C:\web2py\gluon\restricted.py", line 205, in restricted
>>> exec ccode in environment
>>> File "C:\web2py\applications\home\views\default/index.html", line 64,
>>> in <module>
>>> File "C:\web2py\gluon\globals.py", line 182, in write
>>> self.body.write(xmlescape(data))
>>> File "C:\web2py\gluon\html.py", line 114, in xmlescape
>>> return data.xml()
>>> File "C:\web2py\gluon\html.py", line 2146, in xml
>>> return self.serialize(self.data, 0).xml()
>>> File "C:\web2py\gluon\html.py", line 2121, in serialize
>>> li.append(self.serialize(item[3], level+1))
>>> File "C:\web2py\gluon\html.py", line 2109, in serialize
>>> (name, active, link) = item[:3]
>>> ValueError: need more than 0 values to unpack
>>>
>>> On Wednesday, April 11, 2012 11:00:30 PM UTC-5, Cliff wrote:
>>>>
>>>> I have something like this working:
>>>>
>>>> sub_menu = []
>>>> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
>>>> sub_menu = [('Admin', False, URL('admin')), ]
>>>> response.menu = [('Home', False, URL('home','default','index'), []),
>>>> (SPAN('Price List',_style='color:yellow'), True,
>>>> URL('pricelist','default','index'),
>>>> [('Guideline', False, URL('pricelist','default','guideline')),
>>>> ('Multiplier Tables', False,
>>>> URL('pricelist','default','multitable')),
>>>> ('Cut Charge Tables', False,
>>>> URL('pricelist','default','cuttable')),
>>>> (sub_menu),
>>>> ])]
>>>>
>>>> On Wednesday, April 11, 2012 12:24:29 PM UTC-4, Omi Chiba wrote:
>>>>>
>>>>> The following menu works. It's add "Admin" menu next to "Price List"
>>>>> if the user has role "admin". Now, I want to add the "Admin" menu as
>>>>> sub-menu of "Price List" where it's right after the "Cut Charge Tables".
>>>>> How can I do this ?
>>>>>
>>>>> response.menu = [('Home', False, URL('home','default','index'), []),
>>>>> (SPAN('Price List',_style='color:yellow'), True,
>>>>> URL('pricelist','default','index'),
>>>>> [('Guideline', False, URL('pricelist','default','guideline')),
>>>>> ('Multiplier Tables', False,
>>>>> URL('pricelist','default','multitable')),
>>>>> ('Cut Charge Tables', False,
>>>>> URL('pricelist','default','cuttable')),
>>>>> ])]
>>>>>
>>>>> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
>>>>> response.menu += [('Admin', False, URL('admin')), ]
>>>>>
>>>>