Edgewall Software

Ticket #3210 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 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:

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@… 2 years ago.
Fallback handler patch

Change History

Changed 2 years ago by coderanger@…

Fallback handler patch

Changed 2 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.

Changed 2 years ago by athomas

  • status changed from new to closed
  • resolution set to fixed

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

Changed 2 years ago by athomas

Err, insert appropriate check for handler is None

Add/Change #3210 (Modular fallback policy for requests)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from jonas. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.