Using regexps (regular expressions) in your app.yaml url handlers
allows you more control over your URLs and how you structure your
app.  You can also use regexps in your WSGI handlers within your
Python code, either instead of or in addition to the app.yaml
patterns, for more control.

In the example you quoted, they are choosing a Python handler script
based on the URL.  If the request was for "/profile/jim/smith", then
the app.yaml would cause GAE to route the request to a handler in "/
employee/smith/jim.py" (\1 matches the first paren block "jim", \2 the
second "smith", etc.).

Another example:

- url: /cars-by-year-month/(\d+)/(\d+)
  script: /\1/cars.py

That would route "/cars-by-year-month/2007/11" to the script "/2007/
cars.py", which could then further apply regexps to analyze the month
requested, etc.  Each year you would add a new folder (2008,
2009, ...) with a "cars.py" and all information about cars that year.


On Dec 23, 10:38 am, BinaryBird <thefor...@gmail.com> wrote:
> Hello, i am new to google apps engine and also to python. I was
> looking at the script handlers and trying to understand the url
> patters and matching scripts. I was referring 
> thishttp://code.google.com/appengine/docs/configuringanapp.html
> In a example it says " For example, /profile/(.*?)/(.*) would match
> the URL /profile/edit/manager and use edit and manager as the first
> and second groupings. " and
> " handlers:
> - url: /profile/(.*?)/(.*)
>   script: /employee/\2/\1.py
>  "
> and
> " As in the previous example, with the groupings edit and manager, the
> script path /employee/\2/\1.py uses the full path /employee/manager/
> edit.py."
>
> I am trying to understand this particular example. How is the
> directory structure for this particular example maintained and what
> would the names of the corresponding scripts be? Could some one please
> explain a little in detail? Sorry if my questions are stupid as i am
> new to this. Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to