Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Python
branch: inheritance

This branch is 35 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
sql
tests
CHANGELOG.md
README.md

README.md

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 applications.
  • Each application has its 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 config schema.

Functions

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

  • delete_all()

    This function deletes all settings and apps.

Managing Applications

  • 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.
  • SETOF TEXT get_apps()

    • Function returns a set of application names sorted by name.
  • BOOLEAN app_exists(appname TEXT)

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

    • Deletes application info, with all its settings.
  • 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.

Managing Settings

  • 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().
  • TEXT get_value(appname TEXT, optionname TEXT)

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

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

    • Function deletes all options for given app.
  • 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.

  • 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.
  • get_app_info(appname TEXT)

    • Returns information about given application.
  • 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_app_inherits_from(appname TEXT)

    • Function drops the appname inheritance.
  • set_value(appname TEXT, optionname TEXT, value TEXT, inherits_from_app TEXT, inherits_from_optionname 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.
    • The app and option to inherit from should exist, if it does not, then
    • If you want to check if value exists, use the function value_exists().
  • set_option_inherits_from(appname TEXT, optionname TEXT, inherits_from_app TEXT, inherits_from_option TEXT)

    • Function sets the inheritance of the option appname.
    • All apps and options must exist, so the function throws errors if they don't.
  • drop_option_inherits_from(appname TEXT, optionname TEXT)

    • Function drops the option 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.