Unusual use of trac.mimeview.Context
|Reported by:||pipern||Owned by:||Radek Bartoň|
Thanks for writing this plugin! I've been reading through the code to see if we can build on it.
I've found the use of `trac.mimeview.Context`
as a way of passing around the Request and data-dictionary a bit confusing - is there any interest in a patch which switches to a more traditional (IMHO, which may be wrong) Trac-like way of passing the req (and data) object rather than a Context instance? As the Context (when made with
from_request does keep reference to the Request, maybe it's fine to avoid passing ALSO the Request around separately, but it doesn't feel very common - the
Context (from the docstrings) is more about rendering. Grepping for
context.req in discussionplugin causes many hits, but doing the same for other plugins or Trac code shows this is used only rarely.
For example, in `IMessageChangeListener` a context object is needed - but as this object often has extra attributes added, it's not clear what are actually available when implementing this interface. Also, after the call to
message_created, it might/will have extra attributes on it :-) In fact, from reading now, it seems like no actual
trac.mimeview.Context attributes are used in this call.
Some other uses of
Context feel more awkward/unusual:
trac.mimeview.Context has no cursor attribute, but source:discussionplugin/0.11/tracdiscussion/api.py#L170 places a cursor there. Later a lot of other things get put here too - source:discussionplugin/0.11/tracdiscussion/api.py#L301. I understand it's handy to pass around some stafeul object, but feel some dictionary or discussionplugin specific object might be better? Grepping through a lot of plugins and Trac code, I don't see anywhere else that uses a dictionary at context.data when preparing what it's going to give to Genshi for rendering the template.
If we reorganise this a bit, is that interesting to you as a patch?