No activity today, make something!
tiddlyweb TiddlyWeb with PostgreSQL

20160313160634 cdent  

This document describes how to use TiddlyWeb with PostgreSQL. The process is relatively straightforward assuming you want just the default behavior. Installing, configuring and tweaking postgresql is beyond the scope of this document. The project provides good introductory documentation.

See a report for details on how the plugin came about and additional details on how to use it.

Prerequisites

pip install -U tiddlywebplugins.postgresql
  • Create a database to use with TiddlyWeb: createdb tiddlyweb. Replace tiddlyweb with whatever database name you would like to use.

Using

For the sake of an example, we'll create a TiddlyWebWiki instance that stores its data in postgresql.

Creating an instance that uses a database requires additional configuration beyond the usual twinstance call.

In the directory that will contain your instance directory create a temporary tiddlywebconfig.py that looks like this:

config = {
    'server_store': ['tiddlywebplugins.postgresql', {
        'db_config': 'postgresql+psycopg2:///tiddlyweb'}],
}

Replace tiddlyweb with whatever database name you would like to use.

Run twinstance newinstance, replacing newinstance with whatever name you would like to use. This will create the instance. There should be no errors (there may be warnings, usually about unicode handling).

cd newinstance and update the tiddlywebconfig.py you will find there to include the server_store entry from above. It should look something like this:

config = {
    'system_plugins': ['tiddlywebwiki'],
    'secret': 'eabfced158d7096b606f71a5eb894659983b5b29',
    'twanager_plugins': ['tiddlywebwiki'],
    'server_store': ['tiddlywebplugins.postgresql', {
        'db_config': 'postgresql+psycopg2:///tiddlyweb'}],
    # 'indexer': 'tiddlywebplugins.postgresql', # optional
}

Confirm the instance is working by listing the bags in the system with twanager lbags. You should see console, system and common along with their policy information.

Start up the server with twanager server. Visit http://0.0.0.0:8080/recipes/default/tiddlers.wiki and create a new tiddler. Wait for the confirmation message dialog. Reload the page. If the tiddler is in the wiki, things are working.

If it is not, check the tiddlyweb.log for error messages.