plone / bobtemplates.plone

Python Code Templates for Plone Projects with mr.bob
https://pypi.org/project/bobtemplates.plone/
GNU General Public License v2.0
24 stars 31 forks source link

'dict object' has no attribute 'is_plone5' #445

Open NicolasGoeddel opened 4 years ago

NicolasGoeddel commented 4 years ago

I just wanted to add a new content type to my addon and ran into this exception. I am unsure if this is an issue with bobtemplates.plone or mrbob.

As a result it created the following files:

I am still missing the files:

And in case you are wondering. The error also appears if the git is clean and when I remove the space in the content types's name.

Here is the whole log:

(zeocluster) nicolas@Spinnweb:~/Plone/zeocluster/src/example.tools.temporarylink$ mrbob -O example.tools.temporarylink bobtemplates.plone:content_type

Welcome to mr.bob interactive mode. Before we generate directory structure, some questions need to be answered.

Answer with a question mark to display help.
Values in square brackets at the end of the questions show the default value if there is no answer.

RUN: git status --porcelain --ignore-submodules
git status result:
----------------------------
b' M .gitlab-ci.yml\n M setup.cfg\n M setup.py\n M src/example/tools/temporarylink/tool.py\n?? src/example/tools/temporarylink/cipher.py\n'
--> Please commit your changes, before using a sub-template! Continue anyway? [n/y] [n]: y

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

--> Content type description: A root for temporary links.

--> Use XML Model [y]: n

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

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

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

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

Traceback (most recent call last):
  File "/home/nicolas/Plone/zeocluster/bin/mrbob", line 20, in <module>
    sys.exit(mrbob.cli.main())
  File "/home/nicolas/Plone/buildout-cache/eggs/mr.bob-0.1.2-py3.8.egg/mrbob/cli.py", line 175, in main
    c.render()
  File "/home/nicolas/Plone/buildout-cache/eggs/mr.bob-0.1.2-py3.8.egg/mrbob/configurator.py", line 186, in render
    render_structure(self.template_dir,
  File "/home/nicolas/Plone/buildout-cache/eggs/mr.bob-0.1.2-py3.8.egg/mrbob/rendering.py", line 77, in render_structure
    render_template(
  File "/home/nicolas/Plone/buildout-cache/eggs/mr.bob-0.1.2-py3.8.egg/mrbob/rendering.py", line 102, in render_template
    output = renderer(source_output, variables)
  File "/home/nicolas/Plone/buildout-cache/eggs/mr.bob-0.1.2-py3.8.egg/mrbob/rendering.py", line 22, in <lambda>
    jinja2_renderer = lambda s, v: jinja2_env.from_string(s).render(parse_variables(v))
  File "/home/nicolas/Plone/buildout-cache/eggs/Jinja2-2.11.2-py3.8.egg/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/home/nicolas/Plone/buildout-cache/eggs/Jinja2-2.11.2-py3.8.egg/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/home/nicolas/Plone/buildout-cache/eggs/Jinja2-2.11.2-py3.8.egg/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'
NicolasGoeddel commented 4 years ago

To make it work I removed all conditions where is_plone5 was used. For my case it was enough to change these files:

I don't understand why is_plone5 is missing everywhere. Maybe that can be changed somewhere but I don't know where.

MrTango commented 3 years ago

@NicolasGoeddel which version of bobtemplates.plone are you using, in case you have plonecli installed, a plonecli -V will tell you both versions.

NicolasGoeddel commented 3 years ago

I have not installed plonecli. I did not know about it. But we created a similar script by ourselves which essentially can do the same and much more. However I just looked into my buildout-cache and there is bobtemplates.plone in version 5.0.4, mr.bob in version 0.1.2 and mr.developer in version 2.0.0.

These are the versions that got installed automatically by the UnifiedInstaller in version 5.2.1 and got upgraded later by the release-5.2.2-version.cfg and a new buildout.

spanish commented 3 years ago

The same error with plonecli 2.1.2 and bobtemplates.plone 5.2.0.

Solved changing path = configurator.target_directory + "/bobtemplate.cfg" to path = "/myplone/zeocluster/src/my.addon/bobtemplate.cfg" in /usr/local/lib/python3.6/dist-packages/bobtemplates/plone/base.py

Regards