Skip to navigation

Pyplate's Database

Pyplate doesn't store content in the database. Instead content is stored in files in /usr/share/pyplate/content/. The database contains meta data about each page, and information about where each post is stored in /usr/share/pyplate/content/.

When a page is added to a site, a new record is created in the database's pages table. Each record contains the following fields:

FieldDescription
paththe relative path of the page
titlethe title of a post
categorythe category that the post belongs to expressed as a relative path
layoutthe name of the layout that should be used to format the page
descriptiona meta description of what the page is about
tagstags relevant to the page
statusthe status of a page (deleted or published)
pubdatea timestamp of when the page was created
updatea timestamp of when the page was updated

When a new category is added a record is created in the categories table. The categories table has the following fields:

FieldDescription
titlethe title of the category
slugthe text that will be used to represent the category in URLs
paththe relative path of the category
layoutthe name of the layout that should be used to format the page
descriptiona meta description of what the category is about
tagstags relevant to the category
parentthe category that contains this category
placethe position of this category when the contents of the parent category are listed
statusthe status of a category (deleted or published)
pubdatea timestamp of when the category was created
updatea timestamp of when the category was updated

The code to manage the database is in /usr/lib/cgi-bin/db.py. This code handles SQL queries for the database.

Storing relative paths in the database

Pyplate is built on the principle of translating web URLs to local paths. Pyplate uses relative paths extensively as they can easily be translated in to web URLs or file system paths. The relative path of a file or category can be obtained from a URL by removing the domain name. For example, removing the domain name from the following URL will leave the relative path: http://raspberrywebserver.com/linux-basics/bash/bash-basics.html

In this case the relative path is /linux-basics/bash/bash-basics.html. In the filesystem, paths are relative to /usr/share/pyplate/content, so this post can be found in /usr/share/pyplate/content/linux-basics/bash/bash-basics.html.

Share this page:

Follow me