URL can take 0, 1, 2, or 3 un-named argument:
URL(args=[],vars={})
URL(function,args=[],vars={})
URL(controller, function,args=[],vars={})
URL(application, controller, function,args=[],vars={})
args and vars and also optional but, if you pass values for them, they
must be named.
You should not specify application, controller and/or function if they
are the same as the current ones.
Massimo
On Oct 19, 2:28 pm, Stef Mientki <[email protected]> wrote:
> thanks Massimo,
>
> but your answers just makes me more confuse ...
>
> On 19-10-2010 02:06, mdipierro wrote:> Mind that it is not a good idea to do
> this:
>
> > URL("call", "run", "Set_Page", args="77" )
>
> well this the exactly what the books says at page 396,
> and it although I don't understand why "call" and "run" is needed,
> (but I think it has something todo with services)
> but it works.
>
> > i.e. pass the application name. You want instead
>
> > URL("run", "Set_Page", args="77" )
>
> this is not in the book and it doesn't work (in my case) ;-)
>
> here a small overview:
> LSB_Menu.append ( [ 'Stef1', URL("run","Set_Page","77") ]) ## invalid
> request
>
> LSB_Menu.append ( [ 'Stef2', URL("call","run","Set_Page","77") ]) ##
> internal error
> LSB_Menu.append ( [ 'Stef3', "call/run/Set_Page/77" ]) ## OK
> LSB_Menu.append ( [ 'Stef4', URL("call/run/Set_Page/77") ]) ## OK
>
> LSB_Menu.append ( [ 'Stef3', "run/Set_Page/77" ]) ## invalid
> function
> LSB_Menu.append ( [ 'Stef5', URL("run/Set_Page/77") ]) ## invalid
> function
>
> What am I doing wrong ?
>
> thanks,
> Stef
>
> > else if the app is renamed the links break.
>
> > On Oct 18, 6:52 pm, Stef Mientki <[email protected]> wrote:
> >> hello,
>
> >> I'm trying to call a service from menu buttons,
> >> and I read somewhere in the manual, you should always use URL()
>
> >> Now this works:
> >> LSB_Menu.append ( [ 'Stef3',"call/run/Set_Page/77" ])
>
> >> But the following don't (while printing the URL result, looks ok), why ??
> >> #LSB_Menu.append ( [ 'Stef4',URL("call", "run", "Set_Page", args="77" )
> >> ])
> >> #LSB_Menu.append ( [ 'Stef5',URL("call", "run", "Set_Page", vars="77" )
> >> ])
> >> #LSB_Menu.append ( [ 'Stef5',URL("call", "run", "Set_Page", "77" )])
>
> >> # this is the service
> >> from gluon.tools import Service
> >> service = Service(globals())
> >> def call():
> >> return service()
> >> @service.run
> >> def Set_Page(Nr):
> >> return dict ( m='aap',b=99,c=Nr)
>
> >> thanks,
> >> Stef Mientki
>
>