plone / plonecli

Plone Command Line Client - for creating and working with custom add-ons and themes
https://pypi.org/project/plonecli/
Other
19 stars 10 forks source link

create content_type: jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'is_plone5' #69

Open fulv opened 3 years ago

fulv commented 3 years ago

Description

I was trying to add a content type to a package previously created by plonecli.

What I Did


--> Content type name (Allowed: _ a-z A-Z and whitespace) [Todo Task]: PSD X Tool

--> Content type description: 

--> Use XML Model [y]: n

--> Dexterity base class (Container/Item) [Container]: Item

--> Should the content type globally addable? [y]: 

--> Create a content type class [y]: 

--> Activate default behaviors? [y]: n

Traceback (most recent call last):
  File "/usr/local/plone-5.2/zeoserver/bin/plonecli", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/click/core.py", line 1289, in invoke
    rv.append(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/plonecli/cli.py", line 91, in create
    mrbobmain([bobtemplate, "-O", name])
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/mrbob/cli.py", line 175, in main
    c.render()
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/mrbob/configurator.py", line 193, in render
    self.ignored_directories)
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/mrbob/rendering.py", line 82, in render_structure
    renderer,
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/mrbob/rendering.py", line 102, in render_template
    output = renderer(source_output, variables)
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/mrbob/rendering.py", line 22, in <lambda>
    jinja2_renderer = lambda s, v: jinja2_env.from_string(s).render(parse_variables(v))
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 17, in top-level template code
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'is_plone5'```
fulv commented 3 years ago

I found this problem:


> /usr/local/plone-5.2/zeoserver/lib/python3.6/site-packages/bobtemplates/plone/base.py(201)read_bobtemplates_ini()
-> path = configurator.target_directory + "/bobtemplate.cfg"
(Pdb) configurator.target_directory
'/usr/local/plone-5.2/zeoserver/src/my.package/my.package'

Somehow, my.package ends up getting added twice at the end of the target_directory

Then I did this:

(Pdb) configurator.target_directory = '/usr/local/plone-5.2/zeoserver/src/my.package'
(Pdb) c

And it completed without the error above.