ThePloki ThePloki - 1 year ago 121
JSON Question

GAE (Python) Best practice: Load config from JSON file or Datastore?

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 every page load, I load in a JSON file (using

). Should I instead save the JSON to the Datastore and load it through NDB instead?

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

"TITLE": "Test Theme",
"VERSION": "1.0",
"AUTHOR": "ThePloki",
"DESCRIPTION": "A test theme for my platform",

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

{"template":"link", "url":"account", "msg":"Account"},
{"template":"link", "url":"logout", "msg":"Log Out"}

"NAV_LEFT": true,

I don't currently notice any delays, but I'm working locally. During production would the
cause problems if there is high traffic?

Answer Source

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.

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download