Commit 17e6f449 authored by Kirill Smelkov's avatar Kirill Smelkov

jinja2: Fix zc.buildout related import

jinja2_template imports zc.buildout, but uses zc.buildout.buildout (note
the double .buildout). As the result, when tried to use in standalone
mode, importing slapos.recipe.template.jinja2_template fails:

    In [1]: import slapos.recipe.template.jinja2_template
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    Cell In[1], line 1
    ----> 1 import slapos.recipe.template.jinja2_template

    File ~/src/wendelin/slapos/slapos.recipe.template/slapos/recipe/template/jinja2_template.py:56
         53     raise AssertionError(*args)
         54 DEFAULT_CONTEXT['assert'] = _assert
    ---> 56 _buildout_safe_dumps = getattr(zc.buildout.buildout, 'dumps', None)
         57 DUMPS_KEY = 'dumps'
         58 DEFAULT_IMPORT_DELIMITER = '/'

    AttributeError: module 'zc.buildout' has no attribute 'buildout'

That happens because zc.buildout is just a package and does not import
anything from its submodules:

https://lab.nexedi.com/nexedi/slapos.buildout/blob/e9c39301/src/zc/buildout/__init__.py

So the correct way of importing is, thus, import `zc.buildout.buildout`.

-> Fix it.

The bug was there since 65cd02ec (Add jinja2-based template recipe
entry.)

/cc @vpelletier
/reviewed-by @jerome
/reviewed-on nexedi/slapos.recipe.template!9
parent 69a27287
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
############################################################################## ##############################################################################
import os import os
import json import json
import zc.buildout import zc.buildout.buildout
from jinja2 import Environment, StrictUndefined, \ from jinja2 import Environment, StrictUndefined, \
BaseLoader, TemplateNotFound, PrefixLoader BaseLoader, TemplateNotFound, PrefixLoader
import six import six
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment