Skip to content
This repository
branch: python

This branch is 36 commits ahead and 4 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

SConfig 0.10

Description

SConfig is a quite nice way of managing configuration for different programs spread across different machines.

Everything is stored in PostgreSQL database as the central place of all configuration options.

Basic Assumptions

  • There are different applications defined in the database.
  • Each application has its own settings.
  • Each application can inherit its settings from another application. The inherited settings can be overwritten.
  • Normal user cannot change anything in the data otherwise than using the function from the API.
  • All functions and tables are stored in the sconfig schema.

Python API

There is a Python class in sconfig module which implements the thin Python client for the PostgreSQL API.

Functions

The below list of functions contains only functions currently available. In the temp directory there is full list of the API functions.

Deleting all applications and settings

delete_all()
  • Function deletes all settings and apps.

Managing Applications

Creating application

create_app(appname TEXT)
  • Creates application with given name. The name is unique, so if such application exists, the function throws error.
  • This application doesn't inherit from anything.

Creating application with inheritance

create_app(appname TEXT, inherits_from TEXT)
  • Creates application with given name.
  • The name is unique, so if such application exists, the function throws error.
  • The application for the parameter inherits_from must already exist. If it doesn't exist, the function throws error.

Checking if application inherits from another

BOOLEAN inherits_from(appname TEXT, inherits_from TEXT)
  • Returns true if appname inherits from the inherits_from app.
  • False otherwise.
  • If there is no appname app, the exception is thrown.
  • If the inherits_from is null, the error is thrown.

Get list of all applications

SETOF TEXT get_apps()
  • Function returns a set of application names sorted by name.

Check if application exists

BOOLEAN app_exists(appname TEXT)
  • Function returns if application exists, false otherwise.

Delete application with its settings

delete_app(appname TEXT)
  • Deletes application info, with all its settings.

Get all option names for application

SETOF TEXT get_option_names(appname TEXT)
  • Function returns a set of option names for given application.
  • If the application doesn't exist, the function throws exception.

Set inheritance for application

VOID set_app_inherits_from(appname TEXT, inherits_from TEXT)
  • Function sets the inheritance appname. The app must exist, so the function throws errors if it doesn't.

Drop inheritance for an application

drop_inheritance(appname TEXT)
  • Function drops the appname inheritance.

Managing Settings

Set value for application and option

set_value(appname TEXT, optionname TEXT, value TEXT)
  • Function sets value for given appname and optionname.
  • If such option already exists, it will be overwritten without any notice.
  • If the option does not exist, then it will be created.
  • If you want to check if value exists, use the function value_exists().

Get value for application and option

TEXT get_value(appname TEXT, optionname TEXT)
  • Function returns value for given option.
  • If the value doesn't exist, then the function throws exception.

Check if value exists for given application and option

BOOLEAN value_exists(appname TEXT, optionname TEXT)
  • Function returns true if such value exists, false otherwise.

Delete all options for application

delete_option_names(appname TEXT)
  • Function deletes all options for given app.

Get value for application and option with default

TEXT get_value(appname TEXT, optionname TEXT, default TEXT)
  • Function returns value for given option, if the value doesn't exist, then the function returns the default value.

TODO

  • Prepare simple tutorial.

Add functions

get_app_info(appname TEXT)
  • Returns information about given application.

Add Small Fixes:

  • Add trigger to avoid loops in inheritance.

Copyright and License

Copyright (c) 2011, Szymon Guz

This is free software, you can redistribute it and/or modify it under the [PostgreSQL Licence] http://www.opensource.org/licenses/postgresql.

Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.

IN NO EVENT SHALL Szymon Guz BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF $ORGANISATION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Szymon Guz SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND Szymon Guz HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

Something went wrong with that request. Please try again.