devel:blueprints:refactor-mod-python-to-django
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| devel:blueprints:refactor-mod-python-to-django [2011/03/09 08:36] – created morten | devel:blueprints:refactor-mod-python-to-django [2012/10/03 08:29] (current) – old revision restored morten | ||
|---|---|---|---|
| Line 10: | Line 10: | ||
| Often, the handler will include its own dispatch function - it performs varying actions based on the request' | Often, the handler will include its own dispatch function - it performs varying actions based on the request' | ||
| + | |||
| + | A handler does its work, the writes some output back to the client by using the **request object' | ||
| + | |||
| + | NAV's handlers will typically create an instance of a Cheetah template, fill it, get it's output via the '' | ||
| + | |||
| + | ===== Scope ===== | ||
| + | |||
| + | Refactoring a '' | ||
| + | |||
| + | ===== Suggested refactoring steps ===== | ||
| + | |||
| + | The goal is most likely to get rid of the '' | ||
| + | |||
| + | * Split a large '' | ||
| + | * Deconstruct the URI dispatcher into a Django urlconfig. | ||
| + | * Refactor each of the newly created view functions: | ||
| + | * Usage of mod_python' | ||
| + | * Create a '' | ||
| + | |||
| + | A typical handler ends with something like this: | ||
| + | |||
| + | <code python> | ||
| + | req.write(template.respond()) | ||
| + | return apache.OK | ||
| + | </ | ||
| + | |||
| + | Which can be turned into: | ||
| + | |||
| + | <code python> | ||
| + | return HttpResponse(template.respond()) | ||
| + | </ | ||
| + | The '' | ||
| + | |||
| + | ==== Gotchas ==== | ||
| + | * A legacy handler' | ||
| + | |||
| + | ===== Example ===== | ||
| + | |||
| + | Examine these changesets: | ||
| + | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
| + | :!: It's probably better to portion out your refactoring in multiple changesets which make your changes easier to follow. That's one of the things DVCS' | ||
devel/blueprints/refactor-mod-python-to-django.1299659777.txt.gz · Last modified: by morten
