Creating new content types

Introduction

This page is for the programmers, more specifically you need to know how to program in Python. If you don't know about Python it is good to hear that it is a powerful programming language that is rather easy to learn. There are plenty of sources about learning Python, books as well as online resources.

Here I will cover the basics of what you need to know to be successful in writing a new content type. You can also browse the source code in 'alive_cms_project/alive_cms/lib' directory to  see how the content types are done that come with Alive CMS.

A new content type consists of a class that lives in your application's modules folder. The system will import it automagically, it does a "from .... import *" for every Python file in the modules directory, so it is a good idea to use an '__all__ = ["YourClass"]' line so only "YourClass" is imported.

A resource is uniquely defined by it's URL (path). Meta data of an object (resource) is store with the path as the key. An object can also have content data, stored in a record which id is stored in the meta data. Finally you can create many records/data objects without their own meta data (and only accessable via the object's data attribute), see below. Note that any type of resource can live at any path. I'm planning on implementing copy and paste for objects, when that is in place you can effectively move objects to any place after their creation.

Base class and required methods

There are a few requirements to get a content type that actually does something:

See the Hello world code example for some code and hopefully the comments in the code clarify the description above. You can put the code of the example in a site's modules folder and then you should have a content type you can add from the 'folder content' view.

Getting a little more advanced

The stuff above is kind of the bare minimum, let's talk about how to do more features:

 See the Hello foo code example. It shows very simple storage. Put the code in a site's modules folder and play.