I would use the `or' approach for assignement, leaving the routes as
is:

def GET(self, name):
    name = name or 'John'

Then if name is '', John will be used as python consider '' as false.

HTH

r.

On Jan 28, 7:36 pm, Aaron Swartz <[email protected]> wrote:
> > class sayName(app.page):
> >    path = '/sayName/(.*)'
> >    def GET(self, name = 'John'):
> >        return name
>
> > If I visit this url "http://myhost/sayName/joe"; , it prints 'joe'
> > but if I simply visit "http://myhost/sayName/";   without specifying a
> > name, it ignores the default value for name, and it prints nothing.
>
> > Is this a bug, or this is how it's supposed to work?
> > Should I indicate another path in the class instead?
>
> What happens is that the (.*) picks up the value '' (since . means
> zero or more) and then passes this to GET, so GET('') is called and
> the default value is never seen. This might work; I'm not sure:
>
> path = '/sayName/(.+)?'
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to