Modify ↓
Ticket #3210 (closed enhancement: fixed)
Opened 6 years ago
Last modified 6 years ago
Modular fallback policy for requests
| Reported by: | coderanger@… | Owned by: | jonas |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.10 |
| Component: | general | Version: | devel |
| Severity: | normal | Keywords: | |
| Cc: | |||
| Release Notes: | |||
| API Changes: | |||
Description
Attached is a patch against r3356 to implement modular fallback handlers. This allows customizations beyond the simple 404 response. An example handler that uses the wiki is included as WikiFallbackModule.
Attachments
Change History
Changed 6 years ago by coderanger@…
comment:1 Changed 6 years ago by coderanger@…
This idea could probably now be done using the pre/post request processors, if a suitable call was added before rejecting the request.
comment:2 Changed 6 years ago by athomas
- Resolution set to fixed
- Status changed from new to closed
Actually I don't think any changes are required. Something like this should do the job:
class DefaultHandler(Component): implements(IRequestFilter) def pre_process_request(self, req, handler): from trac.wiki.model import WikiPage name = req.path_info.lstrip('/') page = WikiPage(self.env, name) if page.exists: req.redirect(req.href.wiki(name)) else: return handler def post_process_request(self, req, template, content_type): return (template, content_type)
Then in trac.ini:
[trac] request_filters = DefaultHandler
comment:3 Changed 6 years ago by athomas
Err, insert appropriate check for handler is None
Note: See
TracTickets for help on using
tickets.



Fallback handler patch