Changeset 10:d5329a2a05b7 in mailjam for postman/models.py


Ignore:
Timestamp:
May 20, 2012, 9:39:51 AM (12 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

Fully added support for the configuration file. Now all the code uses
postman.conf to read the configuration parameters from it

Added a tests/postman.conf configuration file with specific configurtion
to use while testing (mostly tmp paths)

Updated the run_tests script to delete the temporary directory where
data is saved while running tests

Updated the tests modules/files so they use the tests config file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • postman/models.py

    r5 r10  
    3333    """
    3434
    35     def __init__(self, name, address, members={}, config={}):
     35    def __init__(self, name, address, members={}, configfile=None):
     36        self.configfile = configfile
     37        self.storage_config = config.get_config_parameters('storage',
     38                                                           configfile)
     39        self.archive_config = config.get_config_parameters('archive',
     40                                                           configfile)
     41        self.mailing_config = config.get_config_parameters('mailing_lists',
     42                                                           configfile)
    3643        self.name = name
    3744        self.address = address
    3845        self.members = members
    39         self.config = config
    40         self._validate_config() # validate the config parameters
    4146       
    4247    def __repr__(self):
     
    4550    def __str__(self):
    4651        return self.address
    47 
    48     def _validate_config(self):
    49         if not 'storage' in self.config.keys():
    50             self.config['storage'] = os.path.join(config.storage_path,
    51                                                   'mailings/')
    52         if not 'archive' in self.config.keys():
    53             self.config['archive'] = config.archive_path
    54         if not 'private' in self.config.keys():
    55             self.config['private'] = config.private_mailing
    5652       
    5753    def _validate_member_object(self, member=None):
     
    7167    @property
    7268    def storage(self):
    73         return Storage(os.path.join(self.config['storage'], self.address))
     69        return Storage(os.path.join(self.storage_config['path'], self.address))
    7470
    7571    @property
    7672    def archive(self):
    77         return Storage(os.path.join(self.config['archive'], self.address))
     73        return Storage(os.path.join(self.archive_config['path'], self.address))
    7874   
    7975    def members_addresses(self):
     
    109105        # automagically generates the dict from the instance attributes
    110106        return {'name': self.name, 'address': self.address,
    111                 'members': self.members, 'config': self.config}
     107                'members': self.members, 'configfile': self.configfile}
    112108
    113109    def load(self):
Note: See TracChangeset for help on using the changeset viewer.