Skip to content

Commit ea250ae

Browse files
authored
feat(native): Python - new Jinja API (#7160)
1 parent b918ea7 commit ea250ae

File tree

6 files changed

+399
-51
lines changed

6 files changed

+399
-51
lines changed

.github/workflows/rust-cubesql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949

5050
unit:
5151
runs-on: ubuntu-20.04
52-
timeout-minutes: 50
52+
timeout-minutes: 60
5353
name: Unit (Rewrite Engine)
5454

5555
steps:
@@ -93,7 +93,7 @@ jobs:
9393

9494
unit_legacy:
9595
runs-on: ubuntu-20.04
96-
timeout-minutes: 40
96+
timeout-minutes: 60
9797
name: Unit (Legacy)
9898

9999
steps:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
class JinjaException(Exception):
2+
pass
3+
4+
class JinjaContext:
5+
def function(self, func):
6+
if not callable(func):
7+
raise JinjaException("function registration must be used with functions, actual: '%s'" % type(func).__name__)
8+
9+
return context_func(func)
10+
11+
def filter(self, func):
12+
if not callable(func):
13+
raise JinjaException("function registration must be used with functions, actual: '%s'" % type(func).__name__)
14+
15+
raise JinjaException("filter registration is not supported")
16+
17+
def variable(self, func):
18+
raise JinjaException("variable registration is not supported")
19+
20+
class TemplateModule:
21+
def JinjaContext():
22+
return JinjaContext()
23+
24+
template = TemplateModule
25+
126
def context_func(func):
227
func.cube_context_func = True
328
return func
29+
30+
__all__ = [
31+
'context_func',
32+
'template'
33+
]

0 commit comments

Comments
 (0)