GSoC 2018 Ideas: Improve plonecli and bobtemplates.plone

Improve plonecli and bobtemplates.plone

(Python, Plone, Jinja2)

Summary

Plone uses mrbob and bobtemplates.plone to generate skeletons for Plone packages. This makes it easy for developer to create new addons and also provides best practices in structure and tests. With the recent development in bobtemplates.plone and the new plonecli, we founded the base for a more modular skeleton ecosystem. But we need to cover more parts of the Plone development and need to improve the existing templates, increase the flexibility and test coverage.

This new generation of plonecli and bobtemplates will improve the quality of Plone packages for the whole community. It will also lower the barrier to start with Plone development, as developers can just create functionalities for Plone and get already code and tests which follows known best practices.

For a GSoC student it's a great way to learn Plone and the best practices.

Implementation

The objective is to add some of the missing templates to bobtemplates.plone (portlet, tile, viewlet, view, util) and also to improve existing templates with higher test coverage and more flexibility.

Skills

Basic Python development knowledge is mandatory. Knowledge of Plone and Jinja2 templates is useful but can be achieved during the project. Knowledge of Python and Plone testing is useful, especially plone.app.testing and plone.app.robotframework will be used.

Mentors

Maik Derstappen

Aims

A new version of bobtemplates.plone and plonecli.

2 Likes

This idea has grown out of this discussion about docker support for plonecli.

1 Like

Hello! As of now, what are some of the templates which are present in bobtemplates.plone??

1 Like

Hi, you can find the package and documentation here: GitHub - plone/bobtemplates.plone: Python Code Templates for Plone Projects with mr.bob
Have a look at the docs folder in the repo, as by now the docs are not up to date on docs.plone.org.
Also look at the plonecli package, which uses bobtemplates.plone to build a nice CLI.
GitHub - plone/plonecli: Plone Command Line Client - for creating and working with custom add-ons and themes

1 Like

Hello I am interested in working in this project. I have experience of working in Python frameworks Flask, Jinja2 and also on some other projects in python. I also have experience of building a linux bash shell with basic commands. So i am ready for contributing in it.

Hello!
Could you direct us to some examples of portlets/tiles/viewlets/views/utils that follow some of the best practices?

Greetings, @ayushiiith and @meshde, and welcome to the Plone community.

We're happy you've chosen to join us for your summer of code. Please get started by reading and following the basic instructions at the top of this community forum post. You've already taken the first step! As you learn more over the next weeks about Plone and how it works, please do not hesitate to bring your questions here to this forum. You can search through it for posts from others who have asked the same questions, or start posts of your own. We look forward to helping you.

Once you've become more familiar with what our software does, and once you've learned a bit about developing on Plone and worked on an issue or two from our tracker, you'll want to look over our ideas list and begin thinking about the ways you might contribute. Our ideas represent things we would like to see, but we are also open to your own ideas. Just start a discussion here to find out what the rest of the community thinks. We can help you shape your ideas into solid proposals.

In particular, @meshde, you'll find that there are a number of portlets, tiles, viewlets and such in the Plone core packages. Read our documentation to learn about what each of these things is and how they work

Again, Welcome to the Plone community!

1 Like

Alright! Thank you!

After configuring,registering installing the portlet, how do we go about integrating it into bobtemplates.plone? In general, what are the steps taken to build them?

The purpose of bobtemplates.plone is to help developers by writing a skeleton for a common software component, reducing the amount of code they need to write in order to get started. Components like portlets, tiles, viewlets and so on take a certain amount of boilerplate code to produce, and if we can provide a way to automatically write that code and provide some basic example functionality, it helps new developers to get started writing Plone code.

If you've built a basic portlet, and registered it, then the next step is to make a "template" of it. You might spend some time looking at the templates the bobtemplates.plone already supplies. If you look at them, use them to create some code, and compare the templates and the output, you'll learn how the templates work. And this will help you learn how to templatize your own work.

As I've said elsewhere, though, the point of bobtemplates is to provide best practice code samples, so you will also want to show your work to the community and get input from folks who have worked with Plone for years on what the best practices actually are. That's the challenge of that particular project idea. It's not just producing random code, but code that fits with the community's ideas of best practices. It will take considerable communication and collaboration to do that job well.

When I'm trying to run my buildout(using the command bin/buildout on the terminal) to update changes to my branch of the code(to test out existing add-ons), I'm getting the following error:
Setting socket time out to 3 seconds.
While:
Installing.
Getting section mrbob.
Initializing section mrbob.
Getting option mrbob:backups-dir.
Error: Referenced option does not exist: buildout var-dir
Not able to understand what's wrong. Could you help me out here?

@mrsaicharan1 did you create a portlet in an addon first?
You can use bobtemplates.plone to create an addon package and then inside the package add the needed code for the portlet until it works. When it works you can transform it into a bobtemplate in bobtemplates.plone.
If you don't have much experiance with Plone, maybe start with creating a bobtemplate for a BrowserView or a Viewlet. There are simpler and easier to understand.

But in genral unstand how you add a component like a portlet or a View to Plone and it's possibilities and then create a template which makes theis simpler and faster for every one.

BTW the current master of bobtemplates.plone does not use buildout it self. Only the packages you create with it are containing a buildout and using buildout. So to use bobtemplates.plone only use python pip to install it as documented here: https://github.com/plone/bobtemplates.plone/#installation-in-a-virtualenv
We will propably remove the example with buildout or put it not that prominant as it was until now.
It's easier for people who don't now buildout.

Yeah! I've created an addon by using the plonecli which in turn generated a file structure. I was just testing out some exisiting addons. And that's when I ran into the problem. I will start off by building a viewlet as portlets are based on those. I guess that would give me a base for building a portlet.

Also I had this question..Where does the main code for creating the viewlet go?file structure looked a bit complex.I was thinking it would go in the interfaces.py file. Also after creating the viewlet, without updating the buildout , how do I go about testing it?

maybe create an issue in the bobtemplates.plone repo for every template, then document what peaces are needed for the component. For example collect everthing we need to create a BrowserView as the python file with code, a template file and the zcml registration for it.
I would suggest to start with BrowserView and then Viewlet. portlets are not based on viewlets BTW.
But understanding BrowserViews is key to a lot of peaces.

1 Like

Yeah, I guess that would be a great idea! I'll also be able to learn to collaborate with and get reviews on my code and help me learn in which module what code should go.

I have created a sample browser view with just some HTML code in it(at this location :browser/templates/training.pt) . I have also registered it in configure.zcml. Now when I try to restart plone to test out the code and navigate to this link : http://localhost:8080/Plone/@@training ,It says that the page does not exist. Can you help me out?

Could you just share the relevant part of the code from configure.zcml, so we can see if something went wrong over there?

BTW there are two configure.zcml files. Did you make sure to register the view in the (path to addon package root)/browser/configure.zcml and not (path to addon package root)/configure.zcml?

Yeah. I did register it in the right one. (the one present in browser/configure.zcml). I'll share the code here.