#8021 closed defect (wontfix)
calling add_ctxtnav from IRequestFilter.pre_process_request breaks active flag in mainnav
Reported by: | Owned by: | Remy Blank | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | rendering | Version: | 0.11.2.1 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Adding a local navigation item can be done by a plugin by implementing IRequestFilter and calling add_ctxtnav within pre_process_request, such as in wiki:SubversionLocationPlugin. However this causes the active flag to disappear from the main navigation bar. See for example https://weblion.psu.edu/trac/weblion/browser
To reproduce it, the easiest way is to install wiki:SubversionLocationPlugin or to do a trivial plugin that just implement IRequestFilter and call add_ctxtnav(req, 'TEST') within pre_process_request.
I think this is because the chrome property is not yet ready within the request when calling pre_process_request.
I make a small patch that fix this, but as I'm not a python expert and this involves lazy evaluation of the chrome property I'm not sure if it is right.
Attachments (1)
Change History (6)
by , 16 years ago
Attachment: | requestfilter_add_ctxtnav_active.patch added |
---|
comment:1 by , 16 years ago
Milestone: | → 0.11.3 |
---|---|
Owner: | set to |
I'll look into this. Thanks for reporting the issue.
follow-up: 3 comment:2 by , 16 years ago
I think this is a wontfix
personally, as reading the API docs for pre_process_request()
and post_process_request()
shows that they have different purposes. Here is the docs for pre_
:
"Called after initial handler selection, and can be used to change the selected handler or redirect request."
At this stage your filter cannot know anything about the request, and it may well not be a request involving template rendering at all. By design, there will always be a number of things not yet initalised at the pre
stage.
Use post_process_request()
.
comment:3 by , 16 years ago
Milestone: | 0.11.3 |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
Agreed, closing as wontfix.
comment:4 by , 16 years ago
I understand and agree with your analysis. As I did not know how Genshi worked, I believed that by the time post_process_request() was called, the html page was already generated and it was too late to call add_ctxtnav(). But this is not the case, so it is indeed the right way to do it. I'll submit a patch to the plugin maintainer…
comment:5 by , 16 years ago
And I've applied your patch on trunk. Thanks! TracSubversionLocation 1.0.1 should be out momentarily.
patch setting the handler in req.chrome before calling pre_process_request