Edgewall Software
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

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

Download all attachments as: .zip

Change History

Changed 6 years ago by coderanger@…

Fallback handler patch

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

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from jonas. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.