From 3f099c72ffde54b5bd63b7e54d6c8b717a660a63 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Tue, 13 Feb 2007 18:18:09 +0000 Subject: [PATCH] - more setuptools magic - move configuration to config files - default configuration in defaults.cfg - site configuration in gva.cfg git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@221 a67ec6bc-e5d5-0310-a910-815c51eb3124 --- gnuviechadmin/{Defaults.py => defaults.cfg} | 14 +++++------ .../{gva_cfg.py.tmpl => gva.cfg.tmpl} | 25 ++----------------- gnuviechadmin/tables.py | 14 +++++++++-- setup.cfg | 3 +++ setup.py | 20 +++++++++------ 5 files changed, 37 insertions(+), 39 deletions(-) rename gnuviechadmin/{Defaults.py => defaults.cfg} (78%) rename gnuviechadmin/{gva_cfg.py.tmpl => gva.cfg.tmpl} (52%) create mode 100644 setup.cfg diff --git a/gnuviechadmin/Defaults.py b/gnuviechadmin/defaults.cfg similarity index 78% rename from gnuviechadmin/Defaults.py rename to gnuviechadmin/defaults.cfg index 45dea90..fe1f85f 100644 --- a/gnuviechadmin/Defaults.py +++ b/gnuviechadmin/defaults.cfg @@ -19,16 +19,16 @@ # # Version: $Id$ -"""Distributed default settings for significant GnuviechAdmin config -variables.""" - +# Distributed default settings for significant GnuviechAdmin config +# variables. +# # NEVER make site configuration changes to this file. ALWAYS make -# them in gva_cfg.py instead, in the designated area. See the -# comments in that file for details. +# them in gva.cfg instead, in the designated area. See the comments +# in that file for details. -#---------------------------------------------------------------------- +[database] # The database connection string in a format usable for # sqlalchemy. The default is an sqlite in memory database which is not # very usable for a real installation. # -GVA_DBE = 'sqlite:///:memory:' +uri = sqlite:///:memory: diff --git a/gnuviechadmin/gva_cfg.py.tmpl b/gnuviechadmin/gva.cfg.tmpl similarity index 52% rename from gnuviechadmin/gva_cfg.py.tmpl rename to gnuviechadmin/gva.cfg.tmpl index 17b6338..93a920f 100644 --- a/gnuviechadmin/gva_cfg.py.tmpl +++ b/gnuviechadmin/gva.cfg.tmpl @@ -19,30 +19,9 @@ # # Version: $Id$ -"""This is the module which takes your site-specific settings. - -From a raw distribution it should be copied to gva_cfg.py. If you -already have a gva_cfg.py, be careful to add in only the new settings -you want. The complete set of distributed defaults, with annotation, -are in ./Defaults. In mm_cfg, override only those you want to change, -after the - - from Defaults import * - -line (see below).""" - -############################################################### -# Here's where we get the distributed defaults. # - -from Defaults import * - -############################################################### -# Put YOUR site-specific configuration below, in gva_cfg.py . # -# See Defaults.py for explanations of the values. # - -#-------------------------------------------------------------- +[database] # The database connection string in a format usable for # sqlalchemy. For examples see # http://www.sqlalchemy.org/docs/dbengine.myt # -GVA_DBE = 'sqlite:///database.txt' +uri = sqlite:///database.txt diff --git a/gnuviechadmin/tables.py b/gnuviechadmin/tables.py index 7c26e9b..f973f48 100644 --- a/gnuviechadmin/tables.py +++ b/gnuviechadmin/tables.py @@ -20,9 +20,19 @@ # Version: $Id$ from sqlalchemy import * -from gnuviechadmin import gva_cfg +from pkg_resources import Requirement, resource_filename +import ConfigParser, os -meta = BoundMetaData(gva_cfg.GVA_DBE) +config = ConfigParser.ConfigParser() +config.readfp( + open(resource_filename(Requirement.parse('gnuviechadmin'), + 'gnuviechadmin/defaults.cfg'))) +config.read([ + resource_filename(Requirement.parse('gnuviechadmin'), + 'gnuviechadmin/gva.cfg'), + os.path.expanduser('~/.gva.cfg')]) + +meta = BoundMetaData(config.get('database', 'uri')) client_table = Table( 'client', meta, Column('clientid', Integer, primary_key=True), diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..0c3455b --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[egg_info] +tag_build = .dev +tag_svn_revision = 1 diff --git a/setup.py b/setup.py index 648cedf..87a85ff 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ # # Version: $Id$ -from setuptools import setup,find_packages +from setuptools import setup, find_packages try: import buildutils @@ -30,15 +30,21 @@ except ImportError: setup( name = 'gnuviechadmin', version = '0.1', + packages = find_packages(), + scripts = ['bin/createclient', 'bin/listclients'], + + install_requires = ['sqlalchemy >= 0.3.0'], + setup_requires = [], + + include_package_data = True, + exclude_package_data = { '' : ['gva.cfg'] }, + + author = 'Jan Dittberner', + author_email = 'jan@dittberner.info', description = 'gnuviechadmin server administration suite', long_description = """this is a suite of tools for administering a server it contains tools for maintaining e.g. clients, domains, users, mail accounts""", - author = 'Jan Dittberner', - author_email = 'jan@dittberner.info', - url = 'http://www.gnuviech-server.de/gnuviechadmin', - packages = ['gnuviechadmin'], - scripts = ['bin/createclient', 'bin/listclients'], - install_requires = ['sqlalchemy >= 0.3.0'], license= 'GPL', + url = 'http://www.gnuviech-server.de/gnuviechadmin', )