On Tuesday, August 23, 2011 12:14:43 PM UTC-4, Álvaro J. Iradier wrote: > > Hi, > > I've created a component mycomponent.load to be used with the LOAD() > method. But inside the mycomponent.load I want to have a link to > another function in the same controller. > > When I do: {{=URL(r=request, f='otherfunction')}}, the .load extension > is automatically added, so I end up being linked to the nonexisting > URL "http://.../mycontroller/otherfunction.load". > > Is this the intended behavior? I can guess there is something about > the extension from this fragment of the book: > > > "If you LOAD a component having the .load extension and the > corresponding controller function redirects to another action (for > example a login form), the .load extension propagates and the new url > (the one to redirect too) is also loaded with a .load extension." > > but is there a way to remove the .load extension when using URL inside > a component?
Your component isn't redirecting, so this is not due to the propogation of the .load extension upon redirect. However, the URL function will automatically use the extension of the current request if the extension isn't specified (unless the extension of the current request is html). Since the request that loads the component has a .load extension, the URL function will automatically add a .load extension as well. To avoid this, just specify an explicit extension (e.g., extension='html'). Note, if you want the link to point to an html page, but you don't want the resulting URL to actually include the .html extension, then you can explicitly set extension=False. In that case, web2py will default to requesting the .html view (as it always does when there is no url extension), but it won't show .html in the URL. See near the end of this section in the book: http://web2py.com/book/default/chapter/04#URL. Anthony