On Tuesday, February 7, 2017 at 2:39:43 AM UTC-8, Thomas Moschny wrote:
>
> Hi, 
>
> we have some (internal) plugin that modifies ticket field properties 
> on the fly. It hooks into /ticket and /query requests via 
> IRequestFilter.post_process_request() and modifies data['fields']. 
>
> This worked fine for older Trac versions. But newer Trac seems not to 
> use 'data' in /query requests anymore. Instead the ticket field 
> properties are passed in the global JS 'properties' variable (via 
> add_script_data()). 
>
> Now, in my plugin's post_process_request hook, I can also call 
> add_script_data(). Unfortunately, updating 'properties' doesn't really 
> work that way, as one can only replace whole keys. 
>
> One easy way would be to access req.chrome['script_data'] directly, 
> but that feels a bit like cheating (working around the API). 
>
> Another (more sledgehammery) way would be to add a JS snippet that 
> modifies 'properties'. 
>
> Is there some clean way in between? 
>
> Thanks, 
> Thomas 
>

Looks like you are right about the "properties" dict not being a part of 
"data":
https://trac.edgewall.org/browser/tags/trac-1.2/trac/ticket/query.py?marks=1149-1155#L1148

I haven't done any testing, but I suppose we could put "properties" in 
"data" so that it can be modified in post_process_request. Grabbing it from 
req.chrome['script_data'] sounds like a good workaround.

If you find a modification to Trac that would make your job easier, feel 
free to propose a patch. What changes do you need to make to the 
"properties" dict for your plugin to function correctly?

- Ryan

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to