Deployment

To make use of CodernityDB (or CodernityDB-PyClient), you will need just to create global object that will be available to all your application threads etc.

In general you just need to create database object and then make use of it. No special magic behind this.

Web frameworks

cherrypy

A recommended way would be CherryPy Tool

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python

import cherrypy
from cherrypy.process import plugins
from CodernityDB.database_thread_safe import ThreadSafeDatabase as Database


class CodernityDBPlugin(plugins.SimplePlugin):

    def __init__(self, bus):
        plugins.SimplePlugin.__init__(self, bus)
        self.db = None

    def start(self):
        pass

    def setup_db(self, data, *args, **kwargs):
        if self.db is None:
            codernitydb = cherrypy.config.get('codernitydb')
            if codernitydb:
                path = codernitydb['dir']
            else:
                path = cherrypy.config['codernitydb.dir']
            db = Database(path)
            if db.exists():
                db.open()
            else:
                db.create()
                # add indexes etc...
            self.db = db

    def stop(self):
        if self.db is not None:
            self.db.close()
            self.db = None

Then make use of it as normal CherryPy Tool (see: CherryPy Custom Tools)

flask
See minitwit demo in CodernityDB Demos

UI

GTK
See DesktopRSS demo in CodernityDB Demos