GAE (Python) Best practice: Load config from JSON file or Datastore?
<p>I wrote a platform in GAE Python with a Datastore database (using NDB). My platform allows for a theme to be chosen by the user. Before <em>every</em> page load, I load in a JSON file (using <code>urllib.urlopen(FILEPATH).read()</code>). Should I instead save the JSON to the Datastore and load it through NDB instead?</p>

<p>Here's an example of my JSON config file. These can range in size but not by much. They're generally very small.</p>

<pre><code>{
    "TITLE": "Test Theme",
    "VERSION": "1.0",
    "AUTHOR": "ThePloki",
    "DESCRIPTION": "A test theme for my platform",

    "FONTS": ["Arial", "Times New Roman"],

    "TOOLBAR": [
        {"left":[
            {"template":"logo"}
        ]},
        {"center":[
            {"template":"breadcrumbs"}
        ]},
        {"right":[
            {"template":"link", "url":"account", "msg":"Account"},
            {"template":"link", "url":"logout", "msg":"Log Out"}
        ]}
    ],

    "NAV_LEFT": true,
    "SHOW_PAGE_TITLE": false
}
</code></pre>

<p>I don't currently notice any delays, but I'm working locally. During production would the <code>urllib.urlopen().read()</code> cause problems if there is high traffic?</p>

<p>Do you expect the configuration to change without the application code being re-deployed? That is the scenario where it would make sense to store the configuration in the Datastore.</p>

<p>If the changing the configuration involves re-deploying the code anyway, a local file is probably fine - you might even consider making it a Python file rather than JSON, so that it'd simply be a matter of importing it rather than messing around with file handles.</p>

python json google-app-engine gae-datastore urllib