Bug 1212 - Python module: assign something useful to the per-query data store 'qdata'
Python module: assign something useful to the per-query data store 'qdata'
Status: ASSIGNED
Product: unbound
Classification: Unclassified
Component: server
1.7.0
All All
: P5 enhancement
Assigned To: unbound team
https://github.com/NLnetLabs/unbound/...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-01-27 19:53 CET by episource
Modified: 2018-05-02 11:09 CEST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description episource 2017-01-27 19:53:54 CET
The methods `operate` and `inform_super` both have a parameter named `qdata` which is described as "per query data, here you can store your own data".

However, the python module implementation passes `None` as argument value. There's no way for the python code to assign something else to the per-query data store or modify `None`.

Please consider initializing the per-query data store as `dict`. This would allow the python module script to add custom items.

@github I've prepared a possible patch. Please have a look at: https://github.com/episource/unbound/compare/9a7dfb16f205907413db80eb126c98c08620cef8...episource:dev/pythonmod-data/main

The proposed patch also changes the initialization of the `mod_env` global variable from `None` to a `dict` instance. Certainly, `mod_env` could be ommited completly: If needed, a global variable could be created from the python module's code as well. I see no need for storing the data in the python module's internal C data structures.
Comment 1 episource 2017-03-12 14:59:52 CET
Diff url has changed. The diff against current master can be found here:
https://github.com/episource/unbound/compare/master...episource:dev/pythonmod-data/master
Comment 2 episource 2018-05-01 13:20:39 CEST
I've created a github pull request for this: https://github.com/NLnetLabs/unbound/pull/4
Comment 3 George Thessalonikefs 2018-05-02 11:09:25 CEST
Hi episource,

We are willing to merge your code to unbound's source.
Currently we are releasing 1.7.1, so this code after internal review will be headed for the next release (probably 1.7.2).

Thanks for the contribution!

Best regards,
George