| | 301 | Index: trac/web/api.py |
|---|
| | 302 | =================================================================== |
|---|
| | 303 | --- trac/web/api.py (.../vendor/trac-0.9.4) (revision 25) |
|---|
| | 304 | +++ trac/web/api.py (.../branches/wikiflowpatch/0.9.4) (working copy) |
|---|
| | 305 | @@ -240,7 +240,16 @@ |
|---|
| | 306 | simply send the response itself and not return anything. |
|---|
| | 307 | """ |
|---|
| | 308 | |
|---|
| | 309 | +class IRequestPostProcessor(Interface): |
|---|
| | 310 | + """Extension point interface for request post-processors. |
|---|
| | 311 | + Provides a clean way to override rendering behavior of existing |
|---|
| | 312 | + components.""" |
|---|
| | 313 | |
|---|
| | 314 | + def process(req, template, content_type): |
|---|
| | 315 | + """Do any post-processing the request might need; typically |
|---|
| | 316 | + adding values to req.hdf, or changing template or mime type. |
|---|
| | 317 | + Always returns template and content type, even if unchanged.""" |
|---|
| | 318 | + |
|---|
| | 319 | def absolute_url(req, path=None): |
|---|
| | 320 | """Reconstruct the absolute URL of the given request. |
|---|
| | 321 | |
|---|
| | 322 | Index: trac/web/main.py |
|---|
| | 323 | =================================================================== |
|---|
| | 324 | --- trac/web/main.py (.../vendor/trac-0.9.4) (revision 25) |
|---|
| | 325 | +++ trac/web/main.py (.../branches/wikiflowpatch/0.9.4) (working copy) |
|---|
| | 326 | @@ -23,7 +23,7 @@ |
|---|
| | 327 | from trac.perm import PermissionCache, PermissionError |
|---|
| | 328 | from trac.util import escape, enum, format_datetime, http_date, to_utf8, Markup |
|---|
| | 329 | from trac.web.api import absolute_url, Request, RequestDone, IAuthenticator, \ |
|---|
| | 330 | - IRequestHandler |
|---|
| | 331 | + IRequestHandler, IRequestPostProcessor |
|---|
| | 332 | from trac.web.chrome import Chrome |
|---|
| | 333 | from trac.web.clearsilver import HDFWrapper |
|---|
| | 334 | from trac.web.href import Href |
|---|
| | 335 | @@ -60,6 +60,7 @@ |
|---|
| | 336 | |
|---|
| | 337 | authenticators = ExtensionPoint(IAuthenticator) |
|---|
| | 338 | handlers = ExtensionPoint(IRequestHandler) |
|---|
| | 339 | + post_processors = ExtensionPoint(IRequestPostProcessor) |
|---|
| | 340 | |
|---|
| | 341 | def authenticate(self, req): |
|---|
| | 342 | for authenticator in self.authenticators: |
|---|
| | 343 | @@ -110,6 +111,10 @@ |
|---|
| | 344 | if not content_type: |
|---|
| | 345 | content_type = 'text/html' |
|---|
| | 346 | |
|---|
| | 347 | + for processor in self.post_processors: |
|---|
| | 348 | + template, content_type = processor.process( |
|---|
| | 349 | + req, template, content_type) |
|---|
| | 350 | + |
|---|
| | 351 | req.display(template, content_type or 'text/html') |
|---|
| | 352 | finally: |
|---|
| | 353 | # Give the session a chance to persist changes |
|---|