 I'm Andreas as he said already. I live and work in Germany in a small town in the outskirts of Düsseldorf I'm not really used to giving talks at conferences, so please be patient with me And I hope you can stand my accent for the next 25 minutes This talk is obviously going to be about Cotty it will cover why Cotty came into existence in the first place Who these giants are on whose shoulders Cotty is standing? How Cotty is standing is built on top of them and finally I'll show you some examples to make it easier For you to understand what it's like to work with Cotty So yet another web framework really Aren't there already dozens or even hundreds of them while just pick one of them As a matter of fact all of the Cotty core developers have some common history and that history is blown Plown is a full-featured content management system. It has lots and lots of add-ons and It has some unique features One of them is the object file system, which is a simple yet effective way to persist objects You can more or less store plain Python objects into an object database and it supports a tree or file like folder folder and file like Object tree Plown has some great security features It has the concepts of groups users roles and permissions which enables you to write applications with very fine-grained security Also workflows on absolute killer feature of Plown the office of the underlying soap that was unprecedented at that time So if you have a classic content management use case or you need an enterprise content management system Application, it's probably a perfect solution But if you need to implement a highly customized Application with some CMS like features it can quickly become overkill and a major pain It often has too many features out of the box that you just don't need and you constantly find yourself fighting against the framework This is particularly caused by the underlying software stack The Plown system itself is huge. It consists of some 300 packages It uses multiple competing technologies under the hood Which don't conform to the Zen of Python to have preferably one and exactly one obvious way to do things It's based both on the monolithic soap to and the component based soap three stacks It uses adapters multi adapters utilities all over the place and long story short It doesn't fit my brain So Fortunately, there are smarter people than me who have similar history and wanted to preserve The most important features that soap pioneered back in the days This all with a modern clean and maintainable called code base This was the birth of pyramid then known as reposts BFG The probably greatest thing about pyramid is it even fits my brain. It has a small core It has excellent documentation. It is pythonic and rather low level Which is why you can also sort it into the group of micro frameworks And it's all you also unopinionated which means it makes no assumptions about stuff like persistence and forms And only basic assumptions about authentication and authorization Which you could call the least common denominator for all kinds of web applications This all makes it a great framework framework the framework to build your own framework, which supports your opinions So pyramid only provides what you need in every web application It doesn't come with unneeded ballast and there's no need to waste time fighting the framework's decisions This makes it a perfect foundation for your own framework So what's left to do is make some choices that pyramid doesn't make for us by intention Trusts we need to make are about persistence. Obviously you need some means of storage for most applications templating forms and user input validation and Authentication and authorization sources amongst others So first persistence SQL I can be it's probably the most advanced Python Object relational MEPA out there It's completely database agnostic mean meaning that supports all your relational databases There's many nice useful features that Coty makes use of like hybrid properties association proxies and ordering lists. I won't go into detail here and Particularly useful is that? Transactions can be bound to the life cycle of a pyramid request through the use of the pyramid TM and soap dot sequel alchemy packages So what Coty does is it? implements a note class in pure sequel alchemy that implements what we had with the object file system in soap It follows the adjacency list pattern, which means every note in the tree knows about its parent and its children There obviously is a single root node the one which doesn't have a parent and The note class also supports the dictionary protocol Implementing the dictionary protocol means that you can treat any instance of the note class as kind of dictionary and get Items by their name and key Meaning get children's by their name and you can also set them like you would with the dictionary So this code here actually is working code in Coty which allows you to Get a child of the root element or to add a new child to the root of type document The dictionary protocol allows us instantaneously to Or gives us instantaneously traversal support with pyramid Because pyramid only requires under under get item method to be implemented Which is exactly what the dick protocol does Beyond that we also have an ACL Property on the node class to have persistent and inheritable access control lists In Coty SQL alchemy is set up to do polymorphic queries queries This means a single query can return objects of multiple types. For example, if you query If you're querying for notes It will hand you back instances of document and file if that note happens to be of these types Join table inheritance is another nice feature in SQL alchemy that we use in Coty. It means that the class hierarchy Inheritance hierarchy is broken up among dependent tables So each class is represented by its own table and The respective table only includes attributes that are local to this class The last feature of SQL alchemy that I'd like to mention are events SQL alchemy has a lot of them, but in Coty we actually only use one the before flush event a Flush is basically the moment when SQL alchemy talks to the database It's not the same as a commit. It's rather SQL alchemy Emitting SQL and sending it to the DB which can happen multiple times during a transaction Of course a commit always includes a flush A SQL alchemy before flush event can trigger multiple more nuanced events in Coty This is a mere convenience thing. So it eases you to To have Respective event subscribers So not exactly part of SQL alchemy, but only also closely related and also written by the same author Is a lambic lambic is a package a database migration tool That supports transactional data definition language operations if your database does support it And transactional data manipulation language operations another useful feature is that it Supports multiple environments This comes in extremely handy For add-ons in Coty so each add-on can have its own migration environment, which is independent of the others Coty Includes a script to perform either specific migrations or all migrations for itself and all its add-ons at once You can either upgrade to a specific version or to the latest known revision Downgrades are also supported by a lambic and also by Coty for the case that something goes wrong during a migration and your Database that not does not support transactional data definition language So user interface unless you have a user interface designer on your team And can be sure that he will stay just use bootstraps. You can't do much wrong with it Next forms most form libraries handle creation of forms as well as their validation colander and deform are different in that aspect with colander you can Define the data schema validate and deserialize html forms as well as JSON or XML data and serialize Python structures to Strings mappings and lists that can be consumed by deform Which inform only renders the form? Deform to use of bootstrap 3 out of the box you could change that but we don't need to Because that's the choice we also made for Coty in fact deform 2 is a merge of deform 1 and deform bootstrap which was a package by the Coty developers that Provided default bootstrap templates for deform 1 so repost.workflow is another package from the pylons ecosystem a Content workflow system that supports the concepts of states and transitions states define roles to permission mappings and transitions define transitions between these states and the circumstances in which they might be executed and Actually, this package allows us to implement the complete and exact feature set that We had in soap earlier Depot is another giant that recently made it into Coty I won't cover that because I've seen there's a talk tomorrow at 11 in Barria, too So visit that one and let's finally come to Coty itself As Mentioned in the talk outline Coty is a rather small package that wires up all those giants in a sensible way It was started in 2011 by Daniel Nui and he did the first version In just two days and that already contained the node class with all its features I learned about Coty a year later and joined the project almost immediately I'm skipping the rest because I'm running out of time again already Code quality is an Extremely important thing to us. We have an extensive test suite based on pie test We make heavy use of reusable fixtures that I exported as a pie test plug-in that can be consumed by Coty at once We have continuous integration We use some tools for static source code analysis You shouldn't blindly follow all of their suggestions, but they can give very valuable insights on your code and help you to improve it further so and we also keep to try to keep our requirements up to date and Succeed with that until now Coty is Exclusively configured through any files As Coty is a plain pyramid and therefore also whiskey application you can run it under your preferred whiskey server Almost every aspect of Coty can be configured with with an option in these fights So Coty provides sensible defaults for each option so that you don't have to specify any of them But the important thing to take away from this is you can can overwrite almost everything in Coty But you don't need to I'm skipping those options also So let me just give you one example of how we combine multiple best-of-breed components to a fully functional system With regard to security We use SQL alchemy to store principles that is users and groups in the database and Attach inheritable ACLs to each node use pyramid for the process of authentication on and authorization And we use repose that workflow to recompute these ACLs on every workflow state change so code example People provide a complete Coty's scaffold based on the p create tool from pyramid with Coty and after running the quant You will have a fully functional add-on for Coty with the complete test suite and Continuous integration on Travis also set up already That creative package contains a custom content type default and alternatives used for that type completely set up internationalization structure Also an migration environment for use with a lambic And That scaffold is also always kept up-to-date to adhere to the recent coding conventions as Suggested by the Coty team and it's as well completely tested with on within our continuous integration infrastructure So we can be sure that it works at any time Okay, I have to run a bit first the custom content type looks similar to this it inherits from Coty's content class, which is again just the same default that you should probably inherit all your types from it has a primary and foreign key to the parents table ID column that's needed for the joint table inheritance of sequel alchemy and Then it adds the attributes that are actually added by this class in addition to the inherited ones So last there's a type info that tells Coty how where and under which conditions that content type should be made available through the user interface Which then Results in this drop-down A colander schema is responsible for serialization deserialization validation and form creation 3d form it also inherits from the parents schema and only allows only adds schema Notes that are provided by the custom content class The edit and edit forms They're like everything in Coty plain pyramid to the views that are configured by the usual view config decorator The Actual form rendering and validation is again provided by the base classes So you don't need need to You don't have to write a single line of code for that unless you want something to be done differently And what you see here is a complete and working example. There's nothing left out So this is what the form looks like with a validation error Yeah, last but not least Here's the code for a simple view Again, just ordinary pyramid views just like everything in Coty In this first view there is a template specified for rendering In Coty we use the communion Templating language, but you can choose anything that's supported by pyramid. Okay. I have to come to the end Okay, future of Coty Coty will always stay lean and mean in all of the right ways, so there won't go any Features into the core that can be packaged into an add-on We're even thinking of moving some features out of the core into add-ons For example, we have a mass file upload feature that requires some JavaScript libraries That are rather heavy and only require for that particular feature So the primary goal of Coty is to stay lean and clean Yeah, and We don't have Python 3 support yet, but all of our dependencies Right now supported and It simply hasn't been done, but it shouldn't be a lot of work And if someone would be interested in working on that during the conference, I'd be happy to team up So thank you try out yourself and Thank you for listening Five minutes see any questions. Yes When representing metrics, how do we correctly measure what we care? Thank you so with defining your content types you have the Polymorphic join that will bring back the actual sub or the content types that you declare as You declare more content types on a lot of the Coty queries. Is it doing a join? Across all those tables or what's the impact on performance? It depends how long this drawing gets but actually modern Relational databases are really good at this. So It's never come to an issue for us yet and we have quite large systems with a lot of inheritance and Multi-billion rows, so it it works second question if I may So I downloaded it and was just looking at the debug output with a lot of the ACL checks for like a nested hierarchy of content and it seemed to be querying the database for the same ACL validations Quite a bit for different parts of the UI. So it didn't seem to be caching the result. Is That something that I was just noticing or is it? I Don't know right now. What do you mean by that? You could show me later. Perhaps. Okay. Any more questions? We need to get it on a microphone. So it's Hello, thank you very much for the for the talk. So I'm not very familiar with all these technology I just know the basics what would be the major advantage versus Django or flask for example Yeah, you cannot probably compare it directly you would compare pyramids to flask Which both are my kind of micro frameworks Django is more Macro framework if you will which contains its own its own or am and coty is just Bundle of Technologies that we use in combination with pyramid so if you like to use pyramid and your Preferred persistence layer happens to be sequel alchemy then coty does a lot of things for you already that you can use Any more questions I do have a quick one. What kind of applications do you make with this framework? We do make all kinds of applications Some of them with large user contributed content We do make custom applications Where a small part needs a content management system, but not a full-featured beats like clone or Django CMS or something like that The advantage is that The framework doesn't get in in your way So you basically have a plain pyramid application with all you can do in pyramid coty is nothing more It doesn't add conventions. So it just configures Pyramid in a meaningful way. I think we could say thank you again. Thank you