[Qgis-developer] Expression context and custom functions
Nyall Dawson
nyall.dawson at gmail.com
Sat Sep 5 05:09:44 PDT 2015
On 4 September 2015 at 01:12, Hugo Mercier <hugo.mercier at oslandia.com> wrote:
> Hi,
>
> I am using custom expressions functions for a plugin.
> Something like this :
>
> class MyFunction( QgsExpression.Function ):
> def func( self, values, feature, parent ):
> feature.geometry()
> ...
>
> The problem is that "feature" is now a QgsExpressionContext(), not a
> QgsFeature anymore.
> I cannot find how to access the feature from the context. Did I miss
> something ?
The old API is fixed in 9133538 - sorry about that. I've renamed the
new method to funcV2 in the Python bindings.
> But even with the decorator, the problem is still the same: the
> 'feature' parameter of the custom function is not a QgsFeature anymore
> as it was on previous versions, but a QgsExpressionContext. And it seems
> there is no way to access the feature through the expression context.
> Looking at the source, the feature is stored in a variable called
> "_feature_", but trying to access this from the function returns None.
Should also be fixed with 9133538, but I'd appreciate confirmation.
Cheers,
Nyall
>
> Thanks
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
More information about the Qgis-developer
mailing list