[LNT][PATHCH] collect all directives from lnt.cfg

Daniel Dunbar daniel at zuster.org
Mon Feb 17 10:56:13 PST 2014


On Sun, Feb 16, 2014 at 6:32 PM, Chris Matthews <chris.matthews at apple.com>wrote:

> Okay, I have looked through the code and need some clarifications.
>
> 1. Are you proposing to ditch the "old_config" instance in the App which
> holds the lnt.server.config.Config? Then centralize all LNT config stuff in
> the App.Config?  Or just make old_config a second instance of flask.Config,
> or perhaps have it wrap a flask.Config?
>
> After reading, flask.Config is nothing magic, just a dict which has some
> good import methods.
>

Right.

I don't have a perfectly clear plan for what I would like here, but
probably I want:
1. Get rid of old_config.

2. Keep some kind of config object on lnt.server.instance.Instance, which
could be a flask config, but thats just an implementation detail. It should
be possible to instantiate an Instance without other flask bits.

3. Maybe move all of the frontend-flask specific stuff into a separate
config file that gets handled in the canonical flask way (a load on the
builtin flask object).

Separating the UI/webapp bits from the core LNT bits seems reasonable to
me, what do you think?

 - Daniel



> On Jan 21, 2014, at 3:08 PM, Daniel Dunbar <daniel at zuster.org> wrote:
>
> If we are going to go this route, I think I would rather we just move to
> using Flask's app.config.from_pyfile() and ditch our custom config wrapper.
> We could start by using app.config.from_pyfile() on the lnt.cfg file, and
> then eventually ditch our wrapper once it isn't used, which would probably
> be a simple start to get the equivalent of this patch.
>
>  - Daniel
>
>
> On Tue, Jan 21, 2014 at 10:20 AM, Chris Matthews <chris.matthews at apple.com
> > wrote:
>
>> I'd like to propose LNT collect all configuration directives out of the
>> lnt.cfg configuration file.  My motivation for this is that I have been
>> developing experimental LNT functionality by building flask extensions out
>> of tree, where they don't break things.  Currently the LNT Config class
>> looks for explicit keys in the config file, and adds those to the flask app
>> config.  To allow out of tree modules to add configuration directives, I
>> have patched config so that all directives in the file are added to the
>> config object, making sure not to overwrite any that are there already.
>>
>> diff --git a/lnt/server/config.py b/lnt/server/config.py
>> index
>> 2e146b9fece5adb75cecbea65aa1899261940cb2..6bc5c4d5232332bc4be4e627e365ad2afacebb14
>> 100644
>> --- a/lnt/server/config.py
>> +++ b/lnt/server/config.py
>> @@ -97,13 +97,20 @@ class Config:
>>
>>          secretKey = data.get('secret_key', None)
>>
>> -        return Config(data.get('name', 'LNT'), data['zorgURL'],
>> +        cfg = Config(data.get('name', 'LNT'), data['zorgURL'],
>>                        dbDir, os.path.join(baseDir, tempDir), secretKey,
>>                        dict([(k,DBInfo.fromData(dbDirPath, v,
>>                                                 default_email_config))
>>                                       for k,v in
>> data['databases'].items()]),
>>                        data.get('baselineRevision', '144168'))
>> -
>> +
>> +        # Add any remaining keys to the config object.
>> +        for key, val in data.items():
>> +            if not hasattr(cfg, key):
>> +                setattr(cfg, key, val)
>> +        return cfg
>> +
>> +
>>      @staticmethod
>>      def dummyInstance():
>>          baseDir = tempfile.mkdtemp()
>>
>>
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140217/93c3b625/attachment.html>


More information about the llvm-commits mailing list