Skip to content

Commit

Permalink
feat(native): Python - new Jinja API (#7160)
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr authored Sep 22, 2023
1 parent b918ea7 commit ea250ae
Show file tree
Hide file tree
Showing 6 changed files with 399 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust-cubesql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

unit:
runs-on: ubuntu-20.04
timeout-minutes: 50
timeout-minutes: 60
name: Unit (Rewrite Engine)

steps:
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:

unit_legacy:
runs-on: ubuntu-20.04
timeout-minutes: 40
timeout-minutes: 60
name: Unit (Legacy)

steps:
Expand Down
30 changes: 30 additions & 0 deletions packages/cubejs-backend-native/python/cube/src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
class JinjaException(Exception):
pass

class JinjaContext:
def function(self, func):
if not callable(func):
raise JinjaException("function registration must be used with functions, actual: '%s'" % type(func).__name__)

return context_func(func)

def filter(self, func):
if not callable(func):
raise JinjaException("function registration must be used with functions, actual: '%s'" % type(func).__name__)

raise JinjaException("filter registration is not supported")

def variable(self, func):
raise JinjaException("variable registration is not supported")

class TemplateModule:
def JinjaContext():
return JinjaContext()

template = TemplateModule

def context_func(func):
func.cube_context_func = True
return func

__all__ = [
'context_func',
'template'
]
Loading

0 comments on commit ea250ae

Please sign in to comment.