Skip to content

Commit 5f7a291

Browse files
committedMay 5, 2017
Expose "context" to expression functions
1 parent 028c64e commit 5f7a291

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎python/core/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,17 @@ def func(self, values, context, parent):
8484
feature = None
8585
if context:
8686
feature = context.feature()
87+
8788
try:
8889
if self.expandargs:
8990
values.append(feature)
9091
values.append(parent)
92+
if inspect.getargspec(self.function).args[-1] == 'context':
93+
values.append(context)
9194
return self.function(*values)
9295
else:
96+
if inspect.getargspec(self.function).args[-1] == 'context':
97+
self.function(values, feature, parent, context)
9398
return self.function(values, feature, parent)
9499
except Exception as ex:
95100
parent.setEvalErrorString(str(ex))
@@ -113,6 +118,8 @@ def referencedColumns(self, node):
113118
args = inspect.getargspec(function).args
114119
number = len(args)
115120
arg_count = number - 2
121+
if args[-1] == 'context':
122+
arg_count -= 1
116123
expandargs = True
117124

118125
register = kwargs.get('register', True)

0 commit comments

Comments
 (0)
Please sign in to comment.