On Sunday, October 6, 2013 7:32:48 PM UTC-4, Michael Merickel wrote: > The discussion on raising an exception has was done in > https://github.com/Pylons/pyramid/issues/611 and its subsequent pull > requests https://github.com/Pylons/pyramid/pull/1101 and > https://github.com/Pylons/pyramid/pull/1103. The issue had to do with the > contract defined by route_path, in that it's expected to return a path. >
Thanks! I figured I'd bring it up before it actually gets released anyways. My general opinion hasn't changed, but I think it's best to solve the issue in Akhet which doesn't have as strong as 'contract' and is generally more user friendly for generating urls in templates. > On Sun, Oct 6, 2013 at 4:03 PM, Harvey Smith <hlws...@gmail.com<javascript:> > > wrote: > >> On Sunday, October 6, 2013 4:09:55 PM UTC-4, Mike Orr wrote: >> >> On Sat, Oct 5, 2013 at 12:00 AM, Harvey Smith <hlws...@gmail.com> wrote: >>> > Currently in Pyramid v1.5a2 one cannot easily loop over a list of >>> routes to >>> > generate the URLs (for example to generate a nav menu) if some of the >>> routes >>> > are external and one wished to use URL paths instead of qualified URLs >>> > (easier to server through proxies.) This is because >>> Request.route_path() >>> > will raise an exception when called with an external route. >>> > >>> > Since external routes must contain the qualified URL by definition, it >>> would >>> > be more convenient if Request.route_path() just returned the qualified >>> URL >>> > instead of an exception in these cases. In other words >>> Request.route_path() >>> > should prefer to return URL paths when possible, but not bail out when >>> it's >>> > not. >>> > >>> > Or will this cause some evil side effects I am missing? >>> >>> That could go either way. I normally use route_path() but if I were >>> generating an external URL I'd probably call route_url() to make it >>> clear. On the other hand, I don't see anything wrong with route_path() >>> returning a fully-qualified external URL because an unqualified URL is >>> meaningless in that case. >>> >>> I'm not sure if we should support looping through routes though; that >>> sounds fragile. You'd have to know something about the routes to know >>> if each one was suitable for the menu, and if the routes require >>> parameters you wouldn't be able to generate them without the >>> parameters. >>> >> >> In general I avoid hardcoding URLs into the templates. I generate them >> from the routes I've declared in the main __init__.py file, this way >> if/when a URL changes I can simply change it once in the route >> declaration. In the layout template I generate the main navigation menu by >> looping through the routes. I know what the routes are of course but >> I don't know the current route so this is tested for in the loop in >> order to set the css class in the html tag appropriately. I realize >> there are other ways to solve this problem (using JavaScript perhaps) >> but I've been doing it this way for years (from back with Pylons.) >> >> Now because I generate all my URLs in the templates I use the URL >> generation features of Akhet <https://github.com/Pylons/akhet> ( >> https://github.com/Pylons/akhet) because they >> are shorter and fit my philosophy. I have already submitted a pull >> request to <https://github.com/Pylons/akhet/pull/6> >> Akhet <https://github.com/Pylons/akhet/pull/6> ( >> https://github.com/Pylons/akhet/pull/6) which solves my problem >> at the moment for me. I wasn't sure if maybe it should be altered in >> pyramid proper instead though. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "pylons-devel" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to pylons-devel...@googlegroups.com <javascript:>. >> To post to this group, send email to pylons...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/pylons-devel. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-devel+unsubscr...@googlegroups.com. To post to this group, send email to pylons-devel@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-devel. For more options, visit https://groups.google.com/groups/opt_out.