{{='/%s/' % request.application if URL().startswith('/' + request. application) else '/'}}
Anthony On Thursday, February 28, 2013 12:26:32 PM UTC-5, RHC wrote: > > Niphlod, Antony: Thanks for your prompt replies. > > I can see that request.application will function correctly as web2py will > still handle a URL beginning with the application name even if I have used > routes.py to default to this application, Doing it this way does mean that > I would end up with the application name in some of my URLs, and if I use > the html base element approach then URLs all over the place would end up > getting the application name in them. This seems to negate the benefit of > using routes to hide the application name, except for the initial request > to the domain name, which is unfortunate. I was hoping to keep that > benefit, but I think I will have to manage without it. > > On Thursday, 28 February 2013 16:42:53 UTC, Anthony wrote: >> >> No, just do: >> >> {{='/%s/' % request.application}} >> >> Anthony >> >> On Thursday, February 28, 2013 11:30:53 AM UTC-5, RHC wrote: >>> >>> If I use {{=URL(request.application)}} in the view I get >>> >>> "/Test/default/Test" >>> >>> It has added on the current application and controller path. >>> >>> I would like to get just "/Test/" or, if I have used routes.py to set >>> the default application to Test, maybe just "/". This is why I am trying to >>> use the URL helper rather than just generate the string using >>> request.application on it's own. >>> >>> On Wednesday, 27 February 2013 21:32:48 UTC, Niphlod wrote: >>>> >>>> ehm ... request.application ! >>>> >>>> On Wednesday, February 27, 2013 10:26:51 PM UTC+1, RHC wrote: >>>>> >>>>> I'm trying to use javascript to automatically insert a link to a >>>>> plugin web page within an application. However, the javascript, being a >>>>> static file, has no way of generating a valid URL in the proper web2py >>>>> fashion using a URL helper. >>>>> >>>>> I thought perhaps I could use the base element to re-define the root >>>>> of the application using the URL helper. Then my javascript could then >>>>> just >>>>> insert a link to /plugin_myplugin/index.html for example. >>>>> >>>>> For example in the layout.html I was hoping to use >>>>> >>>>> <base href="{{=URL(...)}"/> >>>>> >>>>> Hoiwever, I am stuck for a way to get the URL helper just to create a >>>>> url path to the application itself. e.g. /myapp/ >>>>> >>>>> I want to use the URL helper so that if I start customising the >>>>> routes.py then the generated url will still be valid. >>>>> >>>>> Any ideas? Is this even possible, if not is there another way to >>>>> approach this? >>>>> >>>>> Thanks, >>>>> >>>>> Richard. >>>>> >>>> -- --- 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/groups/opt_out.