Apologies for my lack of familiarity with the development process on the Pylons project, but if somebody will tell me what needs to happen to get this "fixed" - whether it's file a bug report, edit and submit some code, or just quit whining - I'll be happy to move this issue forward. Cheers! ~br
On Jul 12, 11:18 am, Mike Orr <[email protected]> wrote: > On Mon, Jul 12, 2010 at 9:09 AM, BrianTheLion <[email protected]> wrote: > > I have created a function, myurl, that I use as a replacement for > > pylons.url with the goal of giving fully-qualified URLs by default. I > > implement this functionality by applying the keyword argument > > "qualified=True" to everything. E.g., > > > def myurl(*args,**dargs) : > > dargs['qualified']=True > > return url(*args,**dargs) > > > Now, per the documentation, I have a static route to an external > > website declared as follows: > > > map.connect('create_facebook_page', 'http://www.facebook.com/pages/ > > create.php', _static=True) > > > When I call myurl('create_facebook_page') - hence, > > url( 'create_facebook_page',qualified=True) - I get the nonsensical > > result "http://myhost//www.facebook.com/pages/create.php". > > > To me, this does not seem like the most desirable behavior. Ideally, > > pylons.url would be "smart" enough to know that routes to external > > sites do not need further qualification, and would simply ignore the > > qualified=True option. As a second-best, it would throw an error. > > > Does anyone want to chime in before I file a ticket? I am on v0.9.7. > > Perhaps this is corrected in v1.0? > > No, it's still doing it in Routes 1.12.1 . > > I tend to agree that 'qualified' should be assumed to be true for > external routes, and maybe all the generation options should be > disallowed? I also don't think _static should be necessary because > it's obvious from the route path that it's external. In the routes-exp > branch I automatically make the route external if it contains ":" > before "/". > > """>>> import pkg_resources > >>> d = pkg_resources.get_distribution("Routes") > >>> d.version > '1.12.1' > >>> import routes > >>> m = routes.Mapper() > >>> m.connect("create_facebook_page", > >>> "http://www.facebook.com/pages/create.php", _static=True) > >>> m.generate("create_facebook_page") > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File > "/home/mso/.virtualenvs/cameo2/lib/python2.6/site-packages/routes/mapper.py", > line 809, in generate > for key in route.hardcoded: > AttributeError: 'str' object has no attribute 'hardcoded'>>> # Not sure why I > can't call .generate directly. > >>> url = routes.URLGenerator(m) > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: __init__() takes exactly 3 arguments (2 given)>>> url = > routes.URLGenerator(m, {"HTTP_HOST": "localhost"}) > >>> url("create_facebook_page") > > 'http://www.facebook.com/pages/create.php'>>> url("create_facebook_page", > qualified=True) > > 'http://localhost/http://www.facebook.com/pages/create.php'>>> m = > routes.Mapper() > >>> m.connect("create_facebook_page", > >>> "http://www.facebook.com/pages/create.php") > >>> url = routes.URLGenerator(m, {"HTTP_HOST": "localhost"}) > >>> url("create_facebook_page") > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File > "/home/mso/.virtualenvs/cameo2/lib/python2.6/site-packages/routes/util.py", > line 419, in __call__ > (args, kargs)) > routes.util.GenerationException: Could not generate URL. Called with > args: ('create_facebook_page',) {}>>> # So it doesn't like external routes > created without the _static arg. > >>> url("create_facebook_page", qualified=True) > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File > "/home/mso/.virtualenvs/cameo2/lib/python2.6/site-packages/routes/util.py", > line 419, in __call__ > (args, kargs)) > routes.util.GenerationException: Could not generate URL. Called with > args: ('create_facebook_page',) {} > > """ > > -- > Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
