[lxml-dev] Clean up of extension function implementation

Hi all, I did a lot of cleaning up of my code regarding extension functions and I hope it's now pretty close to 'ready for merging'. You can look at doc/extensions.txt in the scoder2 branch for some examples. One problem, however, remains: the first argument to extension functions, which previously contained the current XPath evaluator. I absolutely cannot see a reason for adding this argument to the call. The only usable thing in the evaluator is the 'evaluate(path)' method, but I wouldn't even bet on it being re-entrant, so I can only hope that no existing code actually uses it. I did not want to break any legacy code by happily changing the argument order of the call, so I just kept that argument in there and added a line in the documentation stating that it should not be used (reserved for future extensions :). The new implementation simply passes None. It looks a bit ugly that way, but, well, we /may/ still succeed in finding a use for it some time after lxml 1.0 ... Have fun, Stefan

Stefan Behnel wrote:
Hi all,
I did a lot of cleaning up of my code regarding extension functions and I hope it's now pretty close to 'ready for merging'.
I'll try to give it a shot today. I was having lots of problems with it a few weeks ago, but was working offline (while traveling) and didn't file any reports, I just reverted to 0.8. My problems weren't with the namespace stuff directly, just scoder2.
You can look at doc/extensions.txt in the scoder2 branch for some examples.
One problem, however, remains: the first argument to extension functions, which previously contained the current XPath evaluator. I absolutely cannot see a reason for adding this argument to the call. The only usable thing in the evaluator is the 'evaluate(path)' method, but I wouldn't even bet on it being re-entrant, so I can only hope that no existing code actually uses it.
I did not want to break any legacy code by happily changing the argument order of the call, so I just kept that argument in there and added a line in the documentation stating that it should not be used (reserved for future extensions :). The new implementation simply passes None.
It looks a bit ugly that way, but, well, we /may/ still succeed in finding a use for it some time after lxml 1.0 ...
Sorry, I don't have an opinion on this. --Paul
participants (2)
-
Paul Everitt
-
Stefan Behnel