Modify ↓
#3210 closed enhancement (fixed)
Modular fallback policy for requests
Reported by: | Owned by: | Jonas Borgström | |
---|---|---|---|
Priority: | normal | Milestone: | 0.10 |
Component: | general | Version: | devel |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal 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 (1)
Change History (4)
by , 18 years ago
comment:1 by , 18 years ago
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 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → 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
Note:
See TracTickets
for help on using tickets.
Fallback handler patch