Edgewall Software

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#3210 closed enhancement (fixed)

Modular fallback policy for requests

Reported by: coderanger@… 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:


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)

patch.txt (2.6 KB ) - added by coderanger@… 14 years ago.
Fallback handler patch

Download all attachments as: .zip

Change History (4)

by coderanger@…, 14 years ago

Attachment: patch.txt added

Fallback handler patch

comment:1 by coderanger@…, 14 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 Alec Thomas, 14 years ago

Resolution: fixed
Status: newclosed

Actually I don't think any changes are required. Something like this should do the job:

class DefaultHandler(Component):

    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:
            return handler

    def post_process_request(self, req, template, content_type):
                return (template, content_type)

Then in trac.ini:

request_filters = DefaultHandler

comment:3 by Alec Thomas, 14 years ago

Err, insert appropriate check for handler is None

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.