Re: [web2py] URL anchor breaks routes
On Feb 13, 2011, at 6:31 PM, Richard Baron Penman wrote: > I do want to remove the /page/ part. > Specifying a list of functions would be fine - how is that done? There's no mechanism for it now; you'll have to use the regex mechanism. I'll look at adding it to the new version. > > > On Mon, Feb 14, 2011 at 1:21 PM, Jonathan Lundell wrote: > On Feb 13, 2011, at 5:53 PM, Plumo wrote: > > In the main routes.py I have: > > > > routes_app = ((r'/(?Pcms|admin)\b.*', r'\g'), > > (r'(.*)', r'cms'), > > (r'/?(.*)', r'cms')) > > The last one is redundant, I think. > > > > > > > And in my application specific routes.py I have: > > > > routes_in = ( > > ('/', '/cms/plugin_wiki/page/index'), > > ('/about', '/cms/plugin_wiki/page/about'), > > ('/faq', '/cms/plugin_wiki/page/faq'), > > ) > > routes_out = [(x, y) for (y, x) in routes_in] > > > > > > Is there a better way to do this using the new version of routes? > > I don't think so. The closest you can come is to make cms and plugin_wiki the > default application and controller, but it won't suppress the function as > long as there's an argument. So you'd end up with paths like /page/index, > page/about, page/faq. > > I could manage something like what you're doing if you'd be prepared to > specify a list of functions in the default controller. >
Re: [web2py] URL anchor breaks routes
I do want to remove the /page/ part. Specifying a list of functions would be fine - how is that done? On Mon, Feb 14, 2011 at 1:21 PM, Jonathan Lundell wrote: > On Feb 13, 2011, at 5:53 PM, Plumo wrote: > > In the main routes.py I have: > > > > routes_app = ((r'/(?Pcms|admin)\b.*', r'\g'), > > (r'(.*)', r'cms'), > > (r'/?(.*)', r'cms')) > > The last one is redundant, I think. > > > > > > > And in my application specific routes.py I have: > > > > routes_in = ( > > ('/', '/cms/plugin_wiki/page/index'), > > ('/about', '/cms/plugin_wiki/page/about'), > > ('/faq', '/cms/plugin_wiki/page/faq'), > > ) > > routes_out = [(x, y) for (y, x) in routes_in] > > > > > > Is there a better way to do this using the new version of routes? > > I don't think so. The closest you can come is to make cms and plugin_wiki > the default application and controller, but it won't suppress the function > as long as there's an argument. So you'd end up with paths like /page/index, > page/about, page/faq. > > I could manage something like what you're doing if you'd be prepared to > specify a list of functions in the default controller.
Re: [web2py] URL anchor breaks routes
On Feb 13, 2011, at 5:53 PM, Plumo wrote: > In the main routes.py I have: > > routes_app = ((r'/(?Pcms|admin)\b.*', r'\g'), > (r'(.*)', r'cms'), > (r'/?(.*)', r'cms')) The last one is redundant, I think. > > > And in my application specific routes.py I have: > > routes_in = ( > ('/', '/cms/plugin_wiki/page/index'), > ('/about', '/cms/plugin_wiki/page/about'), > ('/faq', '/cms/plugin_wiki/page/faq'), > ) > routes_out = [(x, y) for (y, x) in routes_in] > > > Is there a better way to do this using the new version of routes? I don't think so. The closest you can come is to make cms and plugin_wiki the default application and controller, but it won't suppress the function as long as there's an argument. So you'd end up with paths like /page/index, page/about, page/faq. I could manage something like what you're doing if you'd be prepared to specify a list of functions in the default controller.
Re: [web2py] URL anchor breaks routes
In the main routes.py I have: routes_app = ((r'/(?Pcms|admin)\b.*', r'\g'), (r'(.*)', r'cms'), (r'/?(.*)', r'cms')) And in my application specific routes.py I have: routes_in = ( ('/', '/cms/plugin_wiki/page/index'), ('/about', '/cms/plugin_wiki/page/about'), ('/faq', '/cms/plugin_wiki/page/faq'), ) routes_out = [(x, y) for (y, x) in routes_in] Is there a better way to do this using the new version of routes?
Re: [web2py] URL anchor breaks routes
On Feb 10, 2011, at 5:16 PM, Plumo wrote: > so let's say I have mapped /init/default/about to /about > > Then: URL(r=request, c='default', f='about', anchor='company') > will produce: /init/default/about#company > instead of: /about#company OK, I have some more information on this. With the regex URL rewriter (which is the only one in the stable release), the anchor (and query string if there is one) is part of the URL being matched in routes_out. So you need to include it in your regex in order for it to work the way you want. So for example instead of this: routes_out = [ ('/init/default/index', '/'), ] you need this: routes_out = [ (r'/init/default/index(?P(#.*)?)', r'/\g'), ] or more generally: routes_out = [ (r'/init/default/index(?P(\?.*)?)(?P(#.*)?)', r'/\g\g'), ] or combined, if you never need to distinguish the query and anchor: routes_out = [ (r'/init/default/index(?P([?#].*)?)', r'/\g'), ] FWIW, this doesn't arise with the new-style router in the trunk. The downside there is that you can't rewrite the query string or anchor.
Re: [web2py] URL anchor breaks routes
On Feb 10, 2011, at 6:27 PM, Jonathan Lundell wrote: > > On Feb 10, 2011, at 5:16 PM, Plumo wrote: >> so let's say I have mapped /init/default/about to /about >> >> Then: URL(r=request, c='default', f='about', anchor='company') >> will produce: /init/default/about#company >> instead of: /about#company > > Post your routes_out, please. (The reason I ask is that I'm writing unit tests for URL routing, and I want to reproduce the error.)
Re: [web2py] URL anchor breaks routes
On Feb 10, 2011, at 5:16 PM, Plumo wrote: > so let's say I have mapped /init/default/about to /about > > Then: URL(r=request, c='default', f='about', anchor='company') > will produce: /init/default/about#company > instead of: /about#company Post your routes_out, please.
Re: [web2py] URL anchor breaks routes
so let's say I have mapped /init/default/about to /about Then: URL(r=request, c='default', f='about', anchor='company') will produce: /init/default/about#company instead of: /about#company
Re: [web2py] URL anchor breaks routes
On Feb 9, 2011, at 7:37 PM, Plumo wrote: > I use routes to remap URL(controller, function) > I found this fails when an anchor is added: URL(controller, function, > anchor=anchor) > > To keep the routes working my temporary solution is URL(controller, function) > + '#' + anchor > Is there a better way? What do you get, and what do you expect?
[web2py] URL anchor breaks routes
I use routes to remap URL(controller, function) I found this fails when an anchor is added: URL(controller, function, anchor=anchor) To keep the routes working my temporary solution is URL(controller, function) + '#' + anchor Is there a better way?