Google App engine Url Mapping using WSGIAppl and regx grouping Help Needed

Posted by spidee on Stack Overflow See other posts from Stack Overflow or by spidee
Published on 2010-05-19T10:05:36Z Indexed on 2010/05/19 10:10 UTC
Read the original article Hit count: 210

Filed under:
|
|
|

Hi

take this example from google docs

class BrowseHandler(webapp.RequestHandler):

>     def get(self, category, product_id):
>         # Display product with given ID in the given category.
> 
> 
> # Map URLs like /browse/(category)/(product_id) to
> BrowseHandler. application =
> webapp.WSGIApplication([(r'/browse/(.*)/(.*)',
> BrowseHandler)
>                                      ],
>                                      debug=True)
> 
> def main():
>     run_wsgi_app(application)
> 
> if __name__ == '__main__':
>     main()

How can i change the regx groupings so that Product id is optional

ie the url http://yourdomain.com/category will be sent to the browse handler in the current above example you must add a product id or at least the / after the category

ie

http://yourdomain.com/category/

r'/browse/(.)/(.)'

Any ideas?

© Stack Overflow or respective owner

Related posts about app

Related posts about engine