Documentation issue - Create a Plone 5 theme product (addon)

@tdkuehnel Let's try it different, I try to be verbose:

Precondiations: You have a system wide Python 2.7 available. Also, you have virtualenv installed system wide (if not you need to install it).

Step one virtualenv:

  • create a new directory and cd into it.
  • execute virtualenv .

Now you have a Python interpreter isolated from system Python in ./bin/python

Step two: install pip:

Now you have an ./bin/pip in your isolated virtual Python environment. All installed with this pip is installed only in this directory for only this Python interpreter.

Step three: Install mr.bob

  • execute ./bin/pip install bobtemplates.plone
  • (this should install mr.bob as dependency)

Now you have ./bin/mr.bob available. Use it to generate the code and copy the code into the Plone installed by the UnifiedInstaller.

I'm seeing how it could work with the Unified Installer, as that's repeatable.

This gets me a lot further:

  • install using Unified Installer 5.0.7
  • go into the zinstance folder
  • source bin/activate
  • bin/pip install mr.bob
  • bin/pip install bobtemplates.plone
  • cd src
  • mrbob -O plonetheme.tango bobtemplates:plone_addon (answer questions)
  • cd plonetheme.tango
  • pip install zc.buildout (this uses the pip from the UI virtualenv, double check with "which pip" if in doubt)
  • buildout

and away she goes....
Until you hit the next snark, that is,

Error: There is a version conflict.
We already have: pycodestyle 2.3.1
but flake8 3.0.4 requires 'pycodestyle<2.1.0,>=2.0.0'.

but that appears to be a version conflict much later on in the proces, and is probably easily fixable with a version pin. At least the initial steps succeed, using the contained environment of the Unified Installer. Which is better for repeatability and documenting purposes.

@jensens Ok i tried this. With a recent virtualenv i got pip already installed by virtualenv. But then i got an error

[root@webserver plonetheme.tango2]# bin/mrbob -O plonetheme.tango2 bobtemplates:plone_addon

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.

--> What kind of package would you like to create? Choose between 'Basic', 'Dexterity', and 'Theme'. [Basic]: Theme

--> Theme name [Tango2]:

Traceback (most recent call last):
File "bin/mrbob", line 11, in
sys.exit(main())
File "/usr/local/Plone5/zeocluster/src/plonetheme.tango2/lib/python2.6/site-packages/mrbob/cli.py", line 172, in main
c.ask_questions()
File "/usr/local/Plone5/zeocluster/src/plonetheme.tango2/lib/python2.6/site-packages/mrbob/configurator.py", line 231, in ask_questions
self.variables[question.name] = question.ask(self)
File "/usr/local/Plone5/zeocluster/src/plonetheme.tango2/lib/python2.6/site-packages/mrbob/configurator.py", line 297, in ask
f(configurator, self)
File "/usr/local/Plone5/zeocluster/src/plonetheme.tango2/lib/python2.6/site-packages/bobtemplates/hooks.py", line 86, in pre_username
default = get_git_info('user.name')
File "/usr/local/Plone5/zeocluster/src/plonetheme.tango2/lib/python2.6/site-packages/bobtemplates/hooks.py", line 49, in get_git_info
result = subprocess.check_output(gitargs + [value]).strip()
AttributeError: 'module' object has no attribute 'check_output'

because of the system python version 2.6 of the centos 6.3 is too old. I will try again with the Plones 2.7 python in a virtualenv in the eventing when i am back at my PC. Thanks a lot so far for your efforts !

Phew, Python 2.6 is really old, this won't work. I was not aware that it is still around.

yep, setting
flake8 = 3.3.0
flake8-isort = 2.2

in buildout.cfg in the generated theme package allows for the whole thing to run through, using just the Unified Installer virtualenv.

@tdkuehnel if you could try it on your system, that would be good.

@polyester, this pinning problem was already addressed, we need a 2.0 release of bobtemplates.plone.

1 Like

Ok, @jensens, with the python from Plone 5.0.7 via unified installer and a recent virtualenv-15.1.0 i had around it worked as you described it ! Just a little warning about "ez_setup.py is deprecated", and that pip was already installed by virtualenv so no need to install it by hand.

@polyester, i can not find any virtualenv in the whole unified installer installed Plone5 directory. I had one laying around and used this, that worked.

Ok, after having a look at the buildout.cfg in the mrbob generated theme addon folder, it looks like it will generate a whole additional plone installation in my theme folder, is this by intention ? I see additional parts as for development, but is this by intention to install a second complete Plone when i only want to create my own theme on the filesystem ? Should'nt i put the necessary parts into my main buildout.cfg in the unified installed plone and work from that ? I am a bit confused now.

You do not need the self contained buildout of your generated add on. Its optional.

You can simply add this newly generated package to the existing Unified Installer based installation you already have.
In section [buildout] of Unified Installers buildout.cfg there is a key develop = (if not add one there). Add there the path to the package generated by mr.bob like so:

develop = 
    /full/path/to/mrbob.generated.package

Hint: it is the path to the generated directory that contains the setup.py file.

Now rerun the bin/buildout of the UnifiedInstaller so it picks up you generated package.
If everything went right, after (re)starting Plone, your generated package is available in the Add Ons Sections of the Plone Control Panel, ready to install.

@jensens, thank you very much ! I will try all steps together now from a fresh install and report if all succeeds and when yes will share what we need to improve the docs.

Update: Plone 5.0.7 successfully installed via unified installer. There is no mr.bob or its templates pre installed.

I put mr.bob and bobtemplates.plone into the eggs section of my main buildout.cfg, the one from the unified installer.

sudo -u plone_buildout bin/buildout

ran sucessfully

executed mrbob, answered the questions to create the templates dir.

At next we need a virtualenv. a

bin/pip install virtualenv

did it, in the main zeocluster directory.

Then i changed into the src/plonetheme.tango dir and initialize it with the virtualenv:

../../virtualenv . --no-site-packages

and then

bin/pip install zc.buildout

At this step i put the generated plonetheme.tango path entry into the develop section of my main unified installed buildout.cfg, ran

sudo -u plone_buildout bin/buildout

and voila, everything worked as expected, um, say, it worked.

So maybe i can strip down all this virtualenv stuff?

Yes i can, just verfied that also.

So these simple steps need to be updated in the docs:

add mr.bob and bobtemplates.plone to the eggs section of the main buildout.cfg. run bin/buildout.

use bin/mrbob to generate a folder with templates, answer the questions and add this package path to the develop section of the buildout, run bin/buildout. Take care of the permission. I used sudo -U plone_buildout for that. All Done ! Hopefully, i better check if my theme package is available in my Plone instance after a restart, wait ...

No, nothing to install in the add ons section or at the theme control panel. But Plone started in the foreground cleanly.

[root@webserver zeocluster]# sudo -u plone_buildout bin/buildout
Develop: '/usr/local/Plone5/zeocluster/src/plonetheme.tango'
Updating zeoserver.
...

mea culpa! I forgot one important detail:

You also need to add the name of the package (plonetheme.tango) to the eggs key (as a new line below the two existing). In the above instructions together with the step where develop = is added/modified. Thus it means you need to run buildout again and restart plone.

@jensens Ok, thank you, i did that and got the following:

[root@webserver zeocluster]# sudo -u plone_buildout bin/buildout
Develop: '/usr/local/Plone5/zeocluster/src/plonetheme.tango'
Updating zeoserver.
Installing client1.
/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/pkg_resources/init.py:183: RuntimeWarning: You have iterated over the result of pkg_resources.parse_version. This is a legacy behavior which is inconsistent with the new version class introduced in setuptools 8.0. In most cases, conversion to a tuple is unnecessary. For comparison of versions, sort the Version instances directly. If you have another use case requiring the tuple, please file a bug with the setuptools project describing that need.
stacklevel=1,
While:
Installing client1.

An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/zc/buildout/buildout.py", line 1995, in main
getattr(buildout, command)(args)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/zc/buildout/buildout.py", line 666, in install
installed_files = self[part]._call(recipe.install)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/zc/buildout/buildout.py", line 1410, in _call
return f()
File "/usr/local/Plone5/buildout-cache/eggs/plone.recipe.zope2instance-4.2.22-py2.7.egg/plone/recipe/zope2instance/init.py", line 113, in install
installed.extend(self.install_scripts())
File "/usr/local/Plone5/buildout-cache/eggs/plone.recipe.zope2instance-4.2.22-py2.7.egg/plone/recipe/zope2instance/init.py", line 617, in install_scripts
requirements, ws = self.egg.working_set(['plone.recipe.zope2instance'])
File "/usr/local/Plone5/buildout-cache/eggs/zc.recipe.egg-2.0.3-py2.7.egg/zc/recipe/egg/egg.py", line 84, in working_set
allow_hosts=self.allow_hosts)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/zc/buildout/easy_install.py", line 859, in install
return installer.install(specs, working_set)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/zc/buildout/easy_install.py", line 634, in install
for spec in specs]
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/pkg_resources/init.py", line 2935, in parse
req, = parse_requirements(s)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/pkg_resources/init.py", line 2883, in parse_requirements
yield Requirement(line)
File "/usr/local/Plone5/zeocluster/lib/python2.7/site-packages/pkg_resources/init.py", line 2892, in init
raise RequirementParseError(str(e))
RequirementParseError: Invalid requirement, parse error at "'/ploneth'"

As so often when i(!) am reading the tracebacks, i really have no clue in which file/line the actual error is. It looks like pkg_resources/init.py parses something inside the theme egg folder, but which file and line it has a problem with? Maybe i patch the init.py to tell me that ...

EDIT: the complete requirement string causing the problem is 'src/plonetheme.tango' as my print statement tells me.

EDIT: making the path in the eggs entry absolute gives same error.

@tdkuehnel: The important part of the traceback you are seeing above is the last line: RequirementParseError: Invalid requirement, parse error at "'/ploneth". This error is telling you that buildout thinks that you've asked it to install a new egg (and you have), but that the "requirement" (which really means the name of the egg, possibly combined with a version pin) is invalid.

Buildout believes that the string "'/ploneth" is all or part of an egg you've asked it to install. My guess is that there is something wrong with the way in which you added the name of your new theme package to the eggs list in the buildout.cfg file. I guess this because that's what you've changed recently, and also because generated theme packages usually start with the namespace "plonetheme".

Egg "requirements" should look like this:

plonetheme.mytheme

Notice that there are no path separators in this line of text, nor are there any quotation marks. This line should be only the name of the package you are trying to add to your buildout (the name of your new theme package).

Find the place where you've added "/ploneth" in your buildout.cfg file and fix it. This error will go away.

@cewing thank you so much for the insight, it worked !

So this whole topic can be broken down to install mr.bob and its templates into the unified installed plone by entries in the main buildout.cfg. Then running a bin/buildout and using mrbob to create the themes folder. Then adding this with two simple entries into the same buildout.cfg and you are ready to go !

Maybe we can add an additional info entry in the mentioned Plone 5 documentation ?

EDIT: Now as i can "see" my mr.bob generated empty theme in the browser interface, when i click "inspect", i get

Warnung Dies ist das Standarddesign (es kann nicht verändert werden)

Maybe the generated theme addon uses some strings or filenames where the configuration screen makes its decision on if this theme is editable or not. Hard for me as a beginner to find that out ...
btw, which is the preferred way to report theme related bugs/issues ? https://github.com/plone/Products.CMFPlone/issues ? I have several typos found in the german translation, too, i would like to contribute.

@tdkuehnel, I'm glad it worked for you. I would agree that some improvement to the documentation is in order. Perhaps you and @svx can work on that together.

As for reporting issues, yes, the issue tracker in github for Products.CMFPlone is the right place. If the issue does not belong there, a community member will help move it to the right place.

c

Just a quick note, scanning through the discussion I didn't see this mentioned. With the unified installer... you get most development stuff, including mr.bob when you run:

bin/buildout -c develop.cfg

My understanding is that the default buildout from the unified installer is more targeted towards production than to development. See https://docs.plone.org/manage/installing/installation.html#install-the-plone-developer-tools for details.

... so, will someone take a crack at filing the documentation issues? Seems that a lot got resolved here and it would be worth helping the next persons avoid having to go through this.

1 Like

With a little helping hand i might be able to do that - so i sum all the things up in a few sentences, refer to this post and file it at the mentioned tracker, is this the way to go ?

1 Like

Yes, recalling only sketchily the full discussion above, the issue could be filed in http://github.com/plone/documentation/issues/ or https://github.com/plone/training/issues/ or https://github.com/plone/Products.CMFPlone/issues/

Ok, thank you, i filed an issue at https://github.com/plone/training/issues/ .
Btw, i feel quite comfortable with the user interface of this community site, it motivated me to keep on going through all this stuff and sharing it so that others could benefit. Nice work, and nice people ! Thank you very much !

1 Like