Attention

This document was written for an old version of Plone, Plone 3, and was last updated 898 days ago.

To learn how to upgrade to the current version of Plone, read the upgrade manual.

SQL backed content types

by Laurence Rowe last modified Dec 06, 2009 09:27 PM
This document gives an example of creating a content type with data stored in an RDBMS (PostgreSQL).

What you need

Aims

  • Content types should be workflowable
  • No stub objects in ZODB (though content should be catalogued)
  • All rows for a table are accessible through a single folder (content cannot be placed anywhere on the site)

Setting up the database

postgres=# create database world with owner plone encoding 'UTF8';
$ psql -d world -f world.sql

Creating our Product

$ mkdir Products/World
$ ./bin/zopectl debug
Starting debugger (the name "app" is bound to the top-level Zope object)
>>> from collective.mercury import codegen
>>> codegen.create_files('Products/World', overwrite=True, annotate=False, drivername='postgres',
... database='world', username='plone', password='plone', host='localhost')

In the products directory should be a folder named World with three files: db.py, autointerfaces.py and automodel.py.

Now create


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.