diff options
| -rw-r--r-- | __init__.py | 6 | ||||
| -rw-r--r-- | server.py | 25 | 
2 files changed, 23 insertions, 8 deletions
diff --git a/__init__.py b/__init__.py index bc8ef5b4..cf9326ca 100644 --- a/__init__.py +++ b/__init__.py @@ -74,10 +74,10 @@ class Soledad(object):          # get config from file          config = configparser.ConfigParser()          config.read(self.config_file) -        if 'soledad-server' in config: +        if 'soledad-client' in config:              for key in default_conf: -                if key in config['soledad-server']: -                    setattr(self, key, config['soledad-server'][key]) +                if key in config['soledad-client']: +                    setattr(self, key, config['soledad-client'][key])      def _init_dirs(self):          if not os.path.isdir(self.prefix): @@ -5,17 +5,32 @@ This should be run with:      twistd -n web --wsgi=leap.soledad.server.application  """ +import configparser  from twisted.web.wsgi import WSGIResource  from twisted.internet import reactor  from u1db.remote import http_app  from leap.soledad.backends.couch import CouchServerState -# TODO: change couch url accordingly -couch_url = 'http://localhost:5984' -state = CouchServerState(couch_url) + +def load_configuration(file_path): +    conf = { +        'couch_url': 'http://localhost:5984', +        'working_dir': '/tmp', +    } +    config = configparser.ConfigParser() +    config.read(file_path) +    if 'soledad-server' in config: +        for key in conf: +            if key in config['soledad-server']: +                conf[key] = config['soledad-server'][key] +    return conf + + +conf = load_configuration('/etc/leap/soledad-server.ini') + +state = CouchServerState(conf['couch_url'])  # TODO: change working dir to something meaningful -state.set_workingdir('/tmp') -# TODO: write a LeapHTTPApp that will use Couch as backend instead of SQLite +state.set_workingdir(conf['working_dir'])  application = http_app.HTTPApp(state)  resource = WSGIResource(reactor, reactor.getThreadPool(), application)  | 
