Changeset 35

Show
Ignore:
Timestamp:
08/23/06 11:42:02 (2 years ago)
Author:
rgrp
Message:

Simplified configuration setup: point to a configuration file using an environment variable (SYSTEMNAME_SETTINGS) and have everything defined in that config file (rather than old approach of pointing to a directory using env variable SYSTEMNAMEHOME and have config file at some location within that).

  • trunk/INSTALL: added information on running tests (including details of how to set up the necessary config file, db and environment variables)
  • trunk/src/dm/environment.py: remove getSystemServicePath and replaced with getConfigFilePath (also added getConfigFilePathEnvironmentVariableName)
    • trunk/src/dm/environmenttest.py: added test for getConfigFilePathEnvironmentVariableName
  • trunk/src/dm/dictionary.py: remove several variables that are not used (system_service_path, etcdir, vardir) and removed/updated various associated methods
  • trunk/etc/domainmodel.conf.new:
    1. cleaned up (removed kforge leftovers)
    2. changed to work with new setup by adding a few variables, removing references to etcdir or vardir etc
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/INSTALL

    r3 r35  
    55    mailto:kforge-dev@lists.okfn.org 
    66 
     7## Full Installation Instructions ## 
    78 
    8 Full installation instructions are below as ``Full Installation Instructions''. 
    9  
    10  
    11 Quickstart 
    12 ++++++++++ 
    13  
    14 1. Check all dependencies (see below). 
    15  
    16  
    17 2. Install package: 
    18  
    19   $ python setup.py install 
    20  
    21  
    22 Full Installation Instructions 
    23 ++++++++++++++++++++++++++++++ 
    24  
    25 DomainModel Package Dependencies 
    26 ******************************** 
     9### 1. Check all dependencies (see below) ### 
    2710 
    2811The system depends on these packages. Please make sure you have them 
     
    4326        python setup.py install 
    4427 
    45 Install DomainModel 
    46 ******************* 
     28### 2. Install package ### 
    4729 
    4830  $ python setup.py install 
    4931 
    50 Testing the Installation 
    51 ************************ 
     32### 3. (optional) Test ### 
     33 
     341. First copy the etc/domainmodel.conf.new and edit the file to be appropriate 
     35   to your installation. 
     36 
     372. Set environment variable DOMAINMODEL_SETTINGS to point to this new 
     38   configuration file. 
     39 
     403. Create a database and database user corresponding to the settings entered in 
     41   the configuration file in step 1 
     42 
     434. Run the tests 
    5244 
    5345  $ ./bin/domainmodel-test 
    5446 
    5547 
    56 Installing DomainModel Applications 
    57 +++++++++++++++++++++++++++++++++++ 
     48## Installing DomainModel Applications ## 
    5849 
    5950Once you have installed the DomainModel package, you can also install 
  • trunk/etc/domainmodel.conf.new

    r29 r35  
    66# system_mode: 
    77#  * whether e.g. in production or development mode 
    8 #  * valid values: production (default) | development 
     8#  * valid values: production | development 
    99system_mode = development 
    1010 
     
    1515#system_name = domainmodel 
    1616 
    17 # system_service_dir: 
    18 #  * path to service home directory 
    19 #  * defined by program environment variable 
    20 #  * NB: included for illustrative purposes only 
    21 #system_service_dir = /path/to/service/files 
    22  
    23 # etcdir: 
    24 #  * path to service configuration directory 
    25 #  * defined by program to be %(system_service_dir)s/etc 
    26 #  * NB: included for illustrative purposes only 
    27 #etcdir = %(system_service_path)s/etc 
    28  
    29 # vardir: 
    30 #  * path to service's variable data directory 
    31 #  * defined by program to be %(system_service_dir)s/var 
    32 #  * NB: included for illustrative purposes only 
    33 #vardir = %(system_service_path)s/var 
    34  
    3517# plugin_data_dir: 
    3618#  * path to service's plugins' variable data directory 
    37 plugin_data_dir = %(vardir)s/plugin_data 
    38  
    39 # project_data_dir: 
    40 #  * path to service's projects' variable data directory 
    41 project_data_dir = %(vardir)s/project_data 
    42  
    43 # ip_address: 
    44 #  * IP address used by Apache virtual-hosts to listen on 
    45 #  * may be set to '*' 
    46 ip_address = * 
    47  
    48 # port_http: 
    49 #  * port number for normal HTTP 
    50 port_http = 9080 
    51  
    52 # port_https: 
    53 #  * port number for secure HTTP 
    54 port_https = 9443 
     19plugin_data_dir = /tmp/domainmodel_testing/plugin_data 
    5520 
    5621# domain_name: 
     
    5823domain_name = modeldomain.your.domain.name 
    5924 
     25 
    6026[logging] 
    61 # default_directory: 
    62 #  * the directory to which logging is directed 
    63 default_directory = %(vardir)s/log 
    64  
    6527# log_file: 
    6628#  * service log file 
    67 log_file = %(default_directory)s/%(system_name)s.log 
     29log_file = %(system_name)s.log 
    6830 
    6931# level: 
    7032#  * level of logging information 
    7133#  * values (increasing verbosity): CRITICAL, ERROR, WARNING, INFO, DEBUG 
    72 level = DEVELOPMENT 
     34level = DEBUG 
    7335 
    7436 
     
    9961 
    10062[www] 
     63# ip_address: 
     64#  * IP address used by Apache virtual-hosts to listen on 
     65#  * may be set to '*' 
     66ip_address = * 
    10167 
    102 # apache_config_file
    103 #  * file path for auto-generated apache configuration 
    104 apache_config_file = %(etcdir)s/httpd.conf 
     68# port_http
     69#  * port number for normal HTTP 
     70port_http = 9080 
    10571 
    106 # ssl_certificate_file: 
    107 #  * path to SSL certificate 
    108 ssl_certificate_file = /etc/apache2/ssl/apache.pem 
    109  
    110 # ssl_certificate_key_file: 
    111 #  * path to SSL certificate keys 
    112 ssl_certificate_key_file = /etc/apache2/ssl/apache.pem 
    113  
    114 # document_root: 
    115 #  * path to directory of web files 
    116 document_root = %(vardir)s/www/  
     72# port_https: 
     73#  * port number for secure HTTP 
     74port_https = 9443 
    11775 
    11876# media_host: 
     
    12684# media_root: 
    12785#  * path to directory of media files 
    128 media_root = %(document_root)s/media 
     86media_root = ./www/media 
    12987 
    13088# reload_apache: 
     
    13694no_reload_apache = true 
    13795 
     96 
    13897[django] 
    13998# templates_dir: 
    14099#  * Django templates to use for web interface  
    141 templates_dir = %(vardir)s/django/templates/kui 
     100# NB: for tests to work this must be set to point to the kforge templates 
     101templates_dir = /path/to/kforge/templates/kui 
    142102 
    143103# secret_key: 
     
    145105#  * NB: make sure your service's secret_key is different from the default 
    146106#  * type one random character (no spaces) for each '#' character in the line: 
    147 # 
    148 #ecret_key = ################################################# 
    149  
    150107secret_key = (*Y£F@{£FHW$Rli(EFH(*SEHF(&9S(P&SYGDF(&G9Ged9f7gs 
    151108 
     
    159116# font_path: 
    160117#  * path to font definition used for captchas 
    161 font_path = %(etcdir)s/FreeMono.ttf 
     118# font_path = /path/to/captcha/FreeMono.ttf 
    162119 
    163120# font_size: 
    164121#  * point size of font used for captchas 
    165 font_size = 48 
    166  
    167  
    168 ## ******************************************************************** 
    169 ## Plugins 
    170 ## ******************************************************************** 
    171  
    172 [moin] 
    173 # system_path: 
    174 #  * path to directory where MoinMoin system data is installed (htdocs etc) 
    175 system_path = /usr/share/moin 
    176  
    177 [trac] 
    178 # templates_path: 
    179 #  * path to directory containing Trac templates 
    180 templates_path = /usr/share/trac/templates 
    181  
    182 # htdocs_path: 
    183 #  * path to htdocs files 
    184 htdocs_path = /usr/share/trac/htdocs 
    185  
     122# font_size = 48 
  • trunk/src/dm/dictionary.py

    r23 r35  
    1313        self.environment = SystemEnvironment(self.getSystemName()) 
    1414        self.assertSystemEnvironment() 
    15         self.readSystemServicePathFromEnvironment() 
    16         self.makeEtcPath() 
    1715        self.setDefaultWords() 
    1816        self.makeConfigFilePath() 
     
    3028        self.environment.assertDjangoSettingsModule() 
    3129         
    32     def readSystemServicePathFromEnvironment(self): 
    33         "Reads system service path from environment." 
    34         self[SYSTEM_SERVICE_PATH] = self.environment.getSystemServicePath() 
    35  
    36     def makeEtcPath(self): 
    37         self[ETC_DIR_PATH] = os.path.join(self[SYSTEM_SERVICE_PATH], 'etc') 
    38  
    3930    def setDefaultWords(self): 
    40         varDirPath = os.path.join(self[SYSTEM_SERVICE_PATH], 'var') 
    41         self[VAR_DIR_PATH] = varDirPath 
    4231        self[PYTHONPATH] = os.environ.get('PYTHONPATH', '') 
    4332        self[SYSTEM_NAME] = self.getSystemName() 
     
    4736        self[VISITOR_ROLE] = 'Visitor' 
    4837        self[INITIAL_PERSON_ROLE] = 'Visitor' 
    49         self[PLUGIN_VAR_DIR_PATH] = os.path.join(varDirPath,'plugin_data') 
    5038        self[PLUGIN_PACKAGE_NAME] = 'dm.plugin' 
    5139        self[CAPTCHA_IS_ENABLED] = '' # False (ConfigParser only supports str) 
     
    5442 
    5543    def makeConfigFilePath(self): 
    56         configFileName = '%s.conf' % self.getSystemName() 
    57         self.configFilePath = os.path.join(self[ETC_DIR_PATH], configFileName) 
     44        self.configFilePath = self.environment.getConfigFilePath() 
    5845 
    5946    def assertConfigFileExists(self): 
     
    6552         
    6653    def initConfigFileReader(self): 
    67         systemName = self[SYSTEM_NAME] 
    68         systemServicePath = self[SYSTEM_SERVICE_PATH] 
    69         self.configFileReader['system_service_path'] = systemServicePath 
    70         self.configFileReader['system_root'] = systemServicePath # depr 
    71         self.configFileReader['system_name'] = systemName 
    72         self.configFileReader['etcdir'] = self[ETC_DIR_PATH] 
    73         self.configFileReader['vardir'] = self[VAR_DIR_PATH] 
     54        for key in self.keys(): 
     55            self.configFileReader[key] = self[key] 
    7456         
    7557    def readConfigFile(self): 
  • trunk/src/dm/environment.py

    r23 r35  
    3030            raise "%(name)s value in environment not valid: '%(value)'" 
    3131 
    32     def getSystemServicePath(self): 
    33         "Reads system service path from SYSTEMNAMEHOME environment variable." 
    34         name = self.systemName.upper() + 'HOME' 
     32    def getConfigFilePathEnvironmentVariableName(self): 
     33        """Get the name of the environment variable which holds the path to the 
     34        configuration file 
     35        """ 
     36        name = self.systemName.upper() + '_SETTINGS' 
     37        return name 
     38 
     39    def getConfigFilePath(self): 
     40        """Read system configuration path from environment variable 
     41        """ 
     42        name = self.getConfigFilePathEnvironmentVariableName() 
    3543        if name in os.environ: 
    36             value = os.environ[name] 
     44            path = os.environ[name] 
    3745        else: 
    3846            message = "Environment variable '%s' not set." % name 
    3947            raise EnvironmentError, message 
    40         if os.path.isdir(value): 
    41             path = value 
    42         else: 
    43             message = 'System service files not found at: %s' % value 
    44             raise EnvironmentError, message 
     48        # if not os.path.isfile(path): 
     49        #     message = 'System service files not found at: %s' % path 
     50        #     raise EnvironmentError, message 
    4551        return path 
    4652 
  • trunk/src/dm/environmenttest.py

    r22 r35  
    1919        self.environment.assertDjangoSettingsModule() 
    2020 
     21    def test_getConfigFilePathEnvironmentVariableName(self): 
     22        exp = 'DOMAINMODEL_SETTINGS' 
     23        out = self.environment.getConfigFilePathEnvironmentVariableName() 
     24        self.failUnlessEqual(exp, out) 
     25