Commit 7f340418 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, @jerome
parent 69a27287
......@@ -26,7 +26,7 @@
##############################################################################
import os
import json
import zc.buildout
import zc.buildout.buildout
from jinja2 import Environment, StrictUndefined, \
BaseLoader, TemplateNotFound, PrefixLoader
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