close Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 2 and Version 3 of RequestHandlers


Ignore:
Timestamp:
Jun 25, 2008, 1:01:38 PM (16 years ago)
Author:
cmlenz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RequestHandlers

    v2 v3  
    1313
    1414This defines a function called `index` that will respond to requests by rendering the template `index.html`.
     15
     16== URL Parts as Parameters ==
     17
     18Any dynamic parts of the URLs defined in the UrlRouting are passed to the request handler as additional parameters. For example:
     19
     20{{{
     21#!python
     22from datetime import datetime
     23from diva import app
     24from diva.templating import output, render
     25
     26@output('index.html')
     27def monthly(request, response, year, month):
     28    return render(month=datetime(year, month, 1))
     29
     30app.routing.add('/archives/{year:\d+}/{month:\d+}/', monthly)
     31}}}
     32
     33Note that in this particular case, the values for `year` and `month` are automatically converted to numbers, due to the use of the `\d+` pattern in the route path.