Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Flask has it's own <code>Config</code> class (a dict subclass) and it will pick out the attributes of the object given to <code>from_object</code>, rather that using the given object as is, as can be seen in the <a href="https://github.com/mitsuhiko/flask/blob/master/flask/config.py#L163" rel="nofollow">source code</a>:</p> <pre><code># class Config(dict): # ... for key in dir(obj): if key.isupper(): self[key] = getattr(obj, key) </code></pre> <p>As you can see, it will only use <em>uppercase</em> attributes.</p> <p>Here's an example <em>by hand</em>:</p> <pre><code>&gt;&gt;&gt; from flask import config &gt;&gt;&gt; class X(object): ... REGULAR = True ... ignored = "not uppercase" ... def __init__(self): ... self.not_used = "because lowercase" ... self.OK = True ... ... @property ... def UPPER_PROP(self): ... return True ... ... @property ... def MIXED_case(self): ... return "wont work" ... &gt;&gt;&gt; x = X() &gt;&gt;&gt; c = config.Config(None) &gt;&gt;&gt; c.from_object(x) &gt;&gt;&gt; c &lt;Config {'REGULAR': True, 'OK': True, 'UPPER_PROP': True}&gt; </code></pre> <p>That said, nothing will hold you back, if you want to implement something like a <a href="http://parand.com/say/index.php/2008/10/24/python-dot-notation-dictionary-access/" rel="nofollow">dot-dict'd</a> subclass of flasks' <code>Config</code>. Whether the potential confusion caused by a non-standard approach outweighs the gains in code readability is something you can decide based on the scope of your project.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload