State of Plone back-end development today
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 50 | |
Author | ||
License | CC Attribution 3.0 Germany: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/55187 (DOI) | |
Publisher | ||
Release Date | ||
Language | ||
Production Year | 2019 |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
Plone Conference 201939 / 50
5
8
10
11
14
16
17
25
26
27
28
29
32
34
35
36
37
41
42
44
46
49
50
00:00
Plane (geometry)Kolmogorov complexitySystem programmingAbstractionMusical ensembleFront and back endsBitMultiplication signSoftware developerJSONXMLComputer animationLecture/Conference
00:35
Plane (geometry)Template (C++)Gamma functionTask (computing)OvalGraphic designFinite element methodTwin primeReading (process)Constraint (mathematics)World Wide Web ConsortiumInstallation artCache (computing)Directory serviceBit rateProcess (computing)Software frameworkRobotCloningFunctional (mathematics)Demo (music)Revision controlNumberCommon Language InfrastructureTemplate (C++)Software testingConfiguration spaceProduct (business)Content (media)Multiplication signRepresentational state transferFlow separationComputer fileVirtual realityText editorRoutingSet (mathematics)Client (computing)MereologyCodeFront and back endsDecision theoryType theoryMultilaterationLocal ring
04:28
Directory serviceView (database)Task (computing)Content (media)Price indexConfiguration spaceInterface (computing)Template (C++)Square numberPlane (geometry)EmailAsynchronous Transfer ModeData structureInteractive televisionMaizeGEDCOMRobotSoftware testingNetwork topologyTemplate (C++)Type theoryContent (media)Task (computing)Computer configurationSoftware testingMultiplication signInheritance (object-oriented programming)MultiplicationSet (mathematics)Computer fileData structureWeb 2.0Endliche ModelltheorieCASE <Informatik>Electronic mailing list1 (number)Source codeComputer animation
06:29
Plane (geometry)Software testingGamma functionTask (computing)World Wide Web ConsortiumLine (geometry)Element (mathematics)Coding theoryInterface (computing)Euclidean vectorContext awarenessQuery languageContent (media)Asynchronous Transfer ModeService (economics)Configuration spaceCellular automatonRepresentational state transferService (economics)Serial portType theoryWeb pageInformationAreaBitSocial classLibrary catalogQuery languageContent (media)Context awarenessTemplate (C++)Revision controlConnectivity (graph theory)Boilerplate (text)Client (computing)Electric generatorToken ringSource code
08:18
Plane (geometry)Execution unitGamma functionTask (computing)MaizeSoftware testingGradientConfiguration spaceDirectory serviceScalable Coherent InterfaceLibrary catalogElectronic visual displayMetadataTemplate (C++)Computer fileProcess (computing)Profil (magazine)Revision controlNumberMetadataWindows RegistryLibrary catalogCodeSubject indexingCommon Language InfrastructureCuboidConfiguration spaceMathematicsCloningCore dumpINTEGRALRepository (publishing)Generic programmingSource code
11:23
Plane (geometry)World Wide Web ConsortiumGamma functionEmbedded systemGame theoryAverageSimultaneous localization and mappingDebuggerCoding theoryPressureSoftware testingComa BerenicesGauge theoryCodeTask (computing)Computer configurationContent (media)Process (computing)Server (computing)RobotScripting languageIntegrated development environmentRevision controlContent (media)Arithmetic meanPoint (geometry)CodeData structureDecision theorySubject indexingComputer fileAsynchronous Transfer ModeMultiplication signMetropolitan area networkDatabaseType theoryMathematicsCombinational logicView (database)CloningLevel (video gaming)BefehlsprozessorDifferent (Kate Ryan album)Power (physics)Computer configurationRevision controlBitCommon Language InfrastructureIntrusion detection systemWeb browserSoftware testingTemplate (C++)Musical ensembleSingle-precision floating-point formatIntegrated development environmentMultiplication
16:15
Plane (geometry)Instance (computer science)Metropolitan area networkComputer configurationRegulärer Ausdruck <Textverarbeitung>Content (media)VotingGamma functionGEDCOMWindows RegistryWide area networkTemplate (C++)Task (computing)Interface (computing)Default (computer science)Field (computer science)CodeWeb browserGUI widget2 (number)Line (geometry)CloningComputer filePoint (geometry)Type theoryExtension (kinesiology)MereologyCASE <Informatik>Multiplication signCodeHuman migrationVariable (mathematics)Content (media)Template (C++)Musical ensembleWindows RegistryContext awarenessField (computer science)Data structureModule (mathematics)Machine codeKey (cryptography)Object (grammar)Software developerSet (mathematics)Configuration spaceDeterminantRevision controlDefault (computer science)Normal (geometry)WindowArray data structureAreaTranslation (relic)Endliche ModelltheorieElectronic mailing listIntegrated development environmentBitSocial classSoftware bugPlug-in (computing)WritingAliasingAuthorization
23:53
Plane (geometry)Electronic data interchangeTemplate (C++)Parity (mathematics)Finite element methodHuman migrationControl flowMaxima and minimaContext awarenessView (database)Standard deviationComputer fileWeb pageGoodness of fitType theorySerial portCloningMathematicsConfiguration spaceCASE <Informatik>Task (computing)Decision theoryTemplate (C++)BitOpen setPhysical systemMultiplication signInterface (computing)Default (computer science)Computer configurationInterpreter (computing)Data structureAdditionCodeDrop (liquid)Moment (mathematics)NamespaceContent (media)Library (computing)Cartesian coordinate systemMaxima and minimaData conversionInheritance (object-oriented programming)User interfaceRepresentational state transferFreewareWeb 2.0Musical ensembleComplete metric spaceMachine codeLine (geometry)Intrusion detection systemSchwerpunktsystemHeegaard splitting
30:31
Complete metric spaceElectronic mailing listFile formatMereologyFunctional (mathematics)Sheaf (mathematics)Variable (mathematics)Point (geometry)Common Language InfrastructureTemplate (C++)View (database)Computer fileBitMultiplication signPhase transitionCloningData structureConfiguration spaceRight angleFeedbackLine (geometry)Lecture/Conference
35:46
Plane (geometry)Kolmogorov complexityAbstractionSystem programmingVideoconferencingMusical ensembleJSONXMLComputer animation
Transcript: English(auto-generated)
00:00
Okay, I want to talk today a bit about back-end development, now how it is today, even though
00:30
everybody talks all the time about headless and front-end. But yeah, you still need back-end. So how can we do that? A small overview, we have things like the
00:49
Plone CLI, some of you might heard about it, I'm pretty sure a lot of people already using Plone API, which is the Python API, which makes things simpler.
01:05
We also have snippets for several editors, also for VS Code, where you can add some code with the editor. And also of course you have the Plone REST API, where you can then
01:27
express these contents to use it on the client side at the end. So the back-end part there will be to customize the REST API to deliver the
01:43
content as they are needed for the front-end. Yeah, of course, if you should use Plone CLI, I think it's useful also for not newcomers. I like to use it,
02:02
of course I build it, but it really saves a lot of time for boring stuff, you can focus on your code. Yeah, it helps you to enhance your products, your add-ons, step-by-step. So if you need a functionality, you can add it, if
02:23
Plone CLI or Bob Templates is providing it. This is just a small demo, so we have a lot of templates already, you can always check the version
02:41
number with the minus capital V, so that you see which version of Plone CLI and Bob Templates you are using, and then you can create your package. Since we need support for Python 3, Python 2, you can set which version you want to use
03:05
for Plone CLI. It's mainly used for creating local virtual environments for testing, and you can always change that and just run Plone CLI build, and it will recreate
03:23
the virtual environment, install the requirements txt, run build out, and then your setup is on Python 2 or Python 3. Yeah, you can see the build command does several steps, the last step
03:42
is to build out, and you don't have to type this manually, but you still can of course. Yeah, there's a small configuration file, this is also the first step when you want to migrate
04:00
an older package to be compatible with Plone CLI, you just create this file. This is the way how Plone CLI finds the package route, but you have also some settings there, and this you can use to, or this Plone CLI and the add-ons will, and the sub-templates will use to make
04:26
decisions later. One example, a content type, that was actually the first template I was working on when I changed to this more modular approach, because it was not possible before
04:45
to create multiple content types, and we just had one big template which were having one example content type. So you can create a content type, you give it a name, you have the option of container an item, if it's global edible or not, and then you have it. If you want to create another
05:08
content type, for example this time we choose item as a base class, this time it's not globally edible, so when we continue then it will ask for parent content type, which in this case is
05:25
the task list, and this Plone CLI will use to generate the tests that they are working, so make sure that the parent content type exists, and then they try to add the content type there, and also the wiring in the FDI settings, so that you don't have to go there and say
05:46
in this container I'm allow the task to be added. Yeah, you can see the structure, it creates basically, it creates a python file for every content type and an XML file.
06:03
Depending on the question of you want to use the XML for or not, you could, we could clean that clean that up, but it's not, it doesn't hurt anybody. You can delete it if you don't want to go that way, or if you say you want to use the supermodel, then you can basically write it in
06:20
XML or do it through the wrap and export the XML after you created your schema. We also have a template for REST API service. For those of you who don't know what the service is, that's the components you have, which for example provides the breadcrumb,
06:46
the navigation, so additional data for your current context. So when you're on the on a page or your custom content type and you want additional data, maybe based on tagging or whatever, so you make a catalog query for that, you can create a service for that and make this
07:05
information available. And with the expand feature of the REST API, you can tell the REST API please also give me this data with the run request I did for the actual context. So you
07:20
just have to customize a bit this area and it will return JSON. The rest is more or less boilerplate. There are two things you decide. One is the class name of the service and one is the actual endpoint name, so the service name, and these things are used to
07:46
add this generation. There's another template coming for serializers. Serializers are you using to change the way how the REST API returns your values. So for example, for vocabularies I did that once because earlier versions of the REST API were just giving you
08:06
the token and you want the title and the token and not ask again for this from the client, so you can change the ways how things are returned to you. There's another one which is
08:22
fairly new, so there might be some bugs, I just found one, but this will help you to easily generate upgrade steps. What we're doing here is basically generate a profile for every upgrade step. This is similar to what Plone does in Plonab upgrades in the core package.
08:45
We will also provide the python file and we will also auto increment the version number, so you don't forget to update or increment the version number in the metadata XML.
09:01
And yeah, if you don't need something, you can always ignore it. So if you don't have python code to write for your upgrade step because the generic setup import is enough, then you're fine. If not, then you can use the python file
09:23
and do for example re-indexing after you imported the profile. So basically you get a file like this for every upgrade step automatically and this includes a folder where you can put profiles like when registry XML or catalog XML
09:47
like I do here in the example, like I will do now. Yeah, this way you can easily create your upgrade steps and there's no excuse to not do it.
10:08
So I think that's basically it. Yeah, if you create more upgrade steps you can see now when we're doing this, it will generate similar structures and we'll go and update the version
10:24
number. So whatever version number you have in your existing package, it will just read it from the metadata and then increment it and that's it. You see, we have a git integration, so every command you make will automatically commit it to your repository and when you did manually
10:46
changes like I did with the catalog XML, then it would tell me maybe you want to commit it before you use templates because the templates from PloneCLI or from Mr. Bob, they're not asking you before they overwrite anything. So if you have conflicting configurations,
11:05
you might lose your changes. So always use the git commit before and then you're fine. It helps you even revert the whole process. You can just go one comment back and nothing happened. Yeah, one other reason is if you use PloneCLI, all the packages are created by this
11:35
will have the same structure. That makes it easy to find things.
11:45
The ideas here are everything has its own folder. So if you create behaviors, they are in behaviors folder. If you create content types, they are content, indexer folder and the upgrades and so forth. There might be some changes like
12:09
I choose viewlets and views to put also in separate folders on the top level. This is a little bit different to the traditional way in having a browser folder,
12:24
but otherwise where would you put viewlets and views? You could put them in browser folder, like a subfolder, but where's the meaning of that? And if you think about newcomers, they don't know the browser folder. They have no idea what is this for and there's no real
12:47
reason to really name it that way. There was at some point in the history, but it's not really that important. That's why the decision was made there.
13:03
It's also more robust. For one thing, you have one place and you generate a new file. So for a new view, you generate a new file. You don't update Python files
13:20
with the generator because when you start this, that can get messy. It shouldn't usually break anything of your code. You would get the test coverage right from the start. Of course, not all the templates have the same amount of tests. Sometimes it's
13:48
just not easy to generate them as a generic test and sometimes I just wait for you to add some. There's a bit of room for improvement, but the whole structure is there so you can go and
14:07
also bring your opinions in and say, yeah, we should use this way or recently we decided to
14:20
rewrite some tests so that we use more the Plone API instead of using get multi adapter to get the view, to test the view and things like that. This makes it easier for newcomers to understand what's happened because the Plone API is more meaningful in how you use it.
14:42
By default, you have in the packages you generate a TOX setup. I said earlier that we have the option to change the Python version and it's easy. It takes a bit of time. If you created a database and you played with it, then you have to delete the database because
15:05
it will not run with Python 2 and 4 in the same way. What TOX does is basically it allows you to have all versions you care about and all combinations of Python and Plone be tested
15:21
without changing anything. You can pick a single environment and say, okay, I just want to test the Python 3.7 with Plone 5.2 and if you don't care about for your add-on for Plone 4, then just go in the TOX-NE and remove the entry for that.
15:53
You can run all these things in parallel too. If you run TOX in the parallel mode, it will use all your CPUs and burn it down. It goes as fast as your CPU power is.
16:09
At the end, you have a summary of that and you see that. Here's an example of the upper part of the TOX-NE. This is what you want to customize.
16:27
The second line, for example, it says this is only for Python 2.7 and then there will be a generated two environments. One is Plone 4.3 and one is Python 5.1. From the third line,
16:45
we will have a version with Python 2.7 with Plone 5.2 and the version with 3.7 and Plone 2. If you go and list the environments, then you see these different versions. You can
17:11
rewrite that so that you have just class and you don't have to test Plone 4. If your add-on will never run on Plone 4. There's another command. If you use TOX-NE,
17:29
it will show you a little bit more environments. These are environments that are defined more or less as a helper. You can use this to update translations and things like that
17:43
or to apply the eyesort. I personally use this in VS Code, so I don't need this, but some people work that way, so it's okay. You can configure the Plone CLI or the Mr. Bob. It works for both for your own taste. If you don't want the git questions,
18:12
then you just say, okay, yeah, just do it. It's a good idea. Always commit and maybe use the Plone version something as default. You have basically two
18:26
areas. The first is the variables, things you put there. You will never see the question, so if you put an answer there, it will be always answered, not asked anymore. If you put it in
18:44
default, you see the question, you see your default. If you press enter, it will just save, but you can change it. The variable names you can find in Bob templates Plone where the templates are defined. In every template folder, you have a Bob.ini file. This Bob.ini file is
19:07
just a normal Windows style. You have the variables defined there and this name you copy. This way, you can do that. We have a little helper in Plone CLI, but we need to
19:26
update to allow more settings. It will write this configuration, at least for the basic stuff that works already. The author name and things like that, it will set, but we could extend this to make more decisions so that you don't have to look for the variables and things like that.
19:45
Would be a nice thing to sprint on. The whole thing is extendable. You can write your own Bob templates packages and register them for Plone CLI. This way, Plone CLI will just list
20:06
them and can use them. It's not hard to do that. This is useful if you have ideas for packages which are maybe customer related or your company way of doing things is different
20:24
and you want to have some of the templates in your own flavor or if you do things which are not necessary for the main development, but you have to think for migrations.
20:41
We can create multiple packages and make them all work with Plone CLI. Here's a little example how that works. It's basically using Python entry points. In your setup UI, you have something like this and you point to your package or in this case,
21:02
Bob templates Plone and there's a Python module, Bob registry and you just have the key there. This is just a little helper object and an entry in that file looks like this. This is the main Plone add-on in this case. You have a Plone CLI alias because we don't want
21:26
to type all the time Plone add-on because we're using the Plone CLI so it's clear we want something related to Plone not to permit. We can skip that, but in the context of Mr. Bob,
21:42
you should use the global name or you could use the global name. You can always say this template depends on Plone add-on because all the sub templates, they expect a certain structure and some files to be there. Usually, you create your add-on with
22:08
the add-on template and after that, you can use all the sub commands. It's not that hard to upgrade your existing if you at some point created your content types. I just did that with the easy newsletter for example. We have a chapter to upgrade existing codes in the documentation
22:27
of Bob templates Plone. If you have questions there, just ping me or one of the others and we will fulfill this. I mentioned a small plugin for VS Code. You can just install it
22:44
like every other VS Code add-on with the extensions. Then you just write Plone and after that, you write something like text line field and then you can jump around filled it out
23:01
and make also the settings for requirement is required or not. We have basically all common fields in Python and also for the supermodel. You can use this in the
23:21
XML or in the Python file. There are also some other settings for the registry XML. For example, some of these big chunks of registry thingies, they are also good things to put in the snippets. There's still one bug here because it should replace the name when you start writing. It
23:45
doesn't do that when you have multiple times, but I already opened the issue there. I mentioned Plone API. It has a really good documentation. It really makes sense. If you
24:03
have people to onboard and start with, we really should use this as much as we can. Just because you can read it and you just understand what's happening. This helps a lot. The other reason is when there will be a change in the future
24:25
under the hood, it's not your problem. You just use the Plone API and the Plone API will use the new way of doing things. Your code is probably also more robust than using some
24:40
internal methods from CMF clone or from whatever. Some ideas for the future. There are some things like views. For example, you can register a view to just appear on
25:03
certain contexts or under certain interfaces and for viewlets too. This is by default already there. You have to go in the CCML file and just change the interface, but it would be nice to have some common options like all the standard content types could be listed there. You can say,
25:25
okay, I want this on pages by default or your own content types which you earlier created could be listed there or something like that. For REST API, I work already on the serializer. Another thing would be the serializer which is the other way around when you send data
25:47
to the REST API in a certain way and you want the REST API to understand your data better, then you can create that. Maybe you have some special data from an application you cannot
26:02
really change or it's just not that common so that you want to do some conversions there. Yes, graphical UI, but just a minimal. For doing things like selecting content types or
26:23
interfaces, also give me the parent content type. We could just select all the container-ish content types from standard clone and from our package. This would be already helpful so you can just select it instead of remember and retype it. But to do that,
26:46
we need to change in the user interface and that means we have to change Mr. Bob itself. I have IDs for that. There are some libraries which work cross-platform and allow you just
27:01
in that moment to have a drop down or things like that. But for that, we have to go upstream before we can use this and pop templates with clone and clone CLI. For VS Code, I wish we would have a better clone API auto-completion at least. It's not working that great when you
27:24
import a clone API like normally people would do with from clone import API and then use it like API content find. VS Code is not that smart with the namespaces there, so there are some
27:43
problems. Also, VS Code by default of course doesn't know the build out structure and things like that. There's a bit of recipe though, so you can create some additional configuration for VS Code and VS Code will read that and then should at least read all your Python paths
28:06
without doing anything else. Another way to do this is using the zop.py Python interpreter you build out usually. Then VS Code also has all the paths in there.
28:25
But yeah, even if you have that, it's not perfect with auto-completion. Yeah, I would like to have more contributions. There is nothing set in stone
28:41
as Philipp said before. Don't be shy. There's no grand jury who makes decisions and because it's there and it looks like this, it has to be like this. That's not the case. So if you have ideas or complaints, open issue, let's discuss
29:02
this. And if you find a way to test things better, just add a test or write a bit documentation would be really helpful. Yeah, if you have other ideas and you're not sure if that makes
29:21
sense to put this in Bob templates, then create other Bob templates packages. Your own would be also helpful at least for you internally, but also to make the whole system a bit more robust. Yeah, VS Code snippets, there were already some contributions. So I guess there are like
29:46
three people from time to time doing something on it. So it's nice to see that in use. I would be at the sprints at least Saturday and maybe Sunday morning. So if you want to
30:02
dive into that, it's a good task for short sprint because there's not that much to learn. So you can achieve some things. Or if you want to work on your custom template and do some stuff, I can just help you if you have questions. Yeah. Any questions so far?
30:38
All right. Is there a Bob template that can create a Bob template? Not yet. I was thinking
30:46
about that because I created so many templates, but I have the feeling we are almost like a feature company. I don't know if it makes sense. It should be possible because what you usually do is you create one Python file and one folder and a bit of structure.
31:07
We could do that. It's still, you have to write a bit of Python for sure because what we are doing with configuration files, usually we pass them, these XML files or XML
31:24
files, we just pass and to keep the format, we don't write them out as XML because the formatting would be different then. So these XML files usually have still a line like earlier, like your custom stuff comes here, so that's a marker. It should stay there.
31:45
But we pass XML, so we find out if we need to add something and if we have to, we insert it after the marker. So that's the way and this is like some Python functions there get called from Mr. Bob. And usually depending on what template you build, you have to
32:09
adjust the parts, the variables you create or define in the pre-render section. So there's a method prevent where it's called and there's some stuff is always the same,
32:24
but things like, I don't know, you have to question upgrade step name or upgrade step title and you want to use this somehow as a variable, then you do the initial JSON there and later in the templates or in the file names or folder names you can use that.
32:44
So that's the work you have always to do, but the structure might be useful. Any other question? So can I customize the command line interface or sub-commands?
33:08
In what way? Like register maybe additional commands or overwrite some commands, their behavior? I mean, CloneCLI itself is just a Python package, so if you have ideas which are generally
33:24
useful, then we can add them. If you create your own Bob templates and you register them with the entry points, they will pop up automatically in CloneCLI. So this add
33:42
command has an auto-completion feature which shows you the list of all templates and you can run them. So these sub-commands for the templates, this is already there, this is customizable. The rest is, it's a Python package. Everything what's possible there. Any other one? Then I have one question. Who of you is
34:13
a beginner or like in a beginning phase? Who is onboarding people from time to time? A couple.
34:32
So if you are using already CloneCLI for that or most of them not, so give it a try.
34:42
I think it's easier to understand and to, you don't have to know all the things, you just create what you want to do. Somebody told you you have to create a view for that and good luck by trying to find the documentation that's sometimes really hurtful even though
35:04
you know what to search for. But it's not easy and with a tool like this, you can just start and then look okay it works and then adjust it. That's way better for beginners. When I started way back then, we had something like this with Zobscale and
35:24
Archetypes support. So you could do similar things and this was really helpful. So give it a try and please also give feedback how that went and what we can do to improve it.
35:44
Okay, thank you, thank you.