Opened 10 years ago
Closed 10 years ago
#12385 closed defect (fixed)
[PATCH] Plugin breaks stream for subsequent plugins
Reported by: | Cinc-th | Owned by: | falkb |
---|---|---|---|
Priority: | normal | Component: | ComponentHierarchyPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description
The line
... html_stream = HTML(stream) ...
in filter_stream()
prevents subsequent plugins from adding stylesheets using add_stylesheet()
.
As soon as one uses HTML()
on a stream this happens. I didn't find the cause for that.
For testing just insert add_stylesheet(req, "foo.css")
:
def filter_stream(self, req, method, filename, stream, data): if req.path_info.startswith('/admin/ticket/components/'): trans = Transformer('//form[@id="modcomp"]/fieldset/div[1]') stream = stream | trans.after(self._parent_component_select(req, data)) elif req.path_info.startswith('/admin/ticket/components'): # add a "parent component" column to the components table stream = stream | Transformer('//table[@id="complist"]/thead/tr/th[3]').after(tag.th("Parent")) html_stream = HTML(stream) # Try adding a stylesheet here add_stylesheet(req, "foo.css") html_comp_list = HTML(html_stream.select('//table[@id="complist"]/tbody')) return html_stream | Transformer('//table[@id="complist"]/tbody').replace(self._insert_parent_column(html_comp_list)) return stream
You'll notice that foo.css
isn't included as a link in the web page delivered by Trac (use the developer tools of your browser, or just look at the head section of the page source).
I suspect the stream is altered in a way that Trac can't inject the link when preparing the page. I noticed that this statement causes XML namespace information to vanish from tag data in the stream when fixing a compatibility problem with SimpleMultiProjectPlugin, see #12367, [14639].
The attached patch uses another method to insert the parent column into the table. This fixes this problem for me.
Attachments (4)
Change History (11)
Changed 10 years ago by
Attachment: | admin.diff added |
---|
comment:1 Changed 10 years ago by
Trac Release: | → 0.12 |
---|
comment:2 Changed 10 years ago by
Status: | new → accepted |
---|
Thanks! Seems to work properly. Lets see what the activities in sibling ticket #12367 will still bring, and if they may change this patch again...
comment:3 Changed 10 years ago by
Revised patch which inserts a parent column even for components without a name. Should finally fix #12367, too.
Changed 10 years ago by
Attachment: | admin-2.diff added |
---|
Revised patch which inserts a parent column even for components without a name.
Changed 10 years ago by
Attachment: | admin-3.diff added |
---|
Add the correct CSS class to empty table cells, too
comment:4 Changed 10 years ago by
Thanks! Could you attach the whole .py file, please? I'm doing this in parallel to other urgent things, so it would ease things here :)
comment:5 Changed 10 years ago by
Yeah, in combination with [14640] of SimpleMultiProjectPlugin, it works properly now with admin-3.diff. Many thanks!!
Patch for adding parent column using injector transformation.