On Jul 2, 2011, at 7:41 AM, Anthony wrote: > On Saturday, July 2, 2011 6:22:15 AM UTC-4, cjrh wrote: > On Jul 1, 8:34 pm, pbreit <pbreit...@gmail.com> wrote: > > I usually do extension='' > > What would extension=None do? It seems to make the most semantic > sense, to me at least. > > The code for URL does this: > > if extension is None and r.extension != 'html': > extension = r.extension > > > So, extension=None results in the extension being set to request.extension > (unless that is already set to 'html'). If extension is set to anything that > evaluates to False (other than None), no extension will be added, as per this > code, which appears later: > > if extension: > function += '.' + extension > > > So, None is a way of getting URL to propogate the current extension, and > anything else that evaluates to False ensures there is no extension. >
Exactly (and extension=None) is the function's default). Notice also that this: > if extension is None and r.extension != 'html': > extension = r.extension make a special case of 'html' only because it's web2py's convention that incoming URLs *without* an extension are treated as 'html', so we suppress 'html' here in the interest of a "cleaner" URL. So, extension=None is saying that we're going to stick with the same extension as the current request, and if it happens to be 'html', we'll preserve that as well, but leave it implicit. extension=False (or anything that evaluates to False) is saying explicitly: no extension at all. Of course, the function that ends up handling the URL can make its own decision about what to return,