[llvm-commits] [zorg] r125891 - /zorg/trunk/llvmlab/llvmlab/ui/app.py
Daniel Dunbar
daniel at zuster.org
Fri Feb 18 08:42:13 PST 2011
Author: ddunbar
Date: Fri Feb 18 10:42:13 2011
New Revision: 125891
URL: http://llvm.org/viewvc/llvm-project?rev=125891&view=rev
Log:
llvmlab.ui.app: Add support for loading a particular config path, and save support.
Modified:
zorg/trunk/llvmlab/llvmlab/ui/app.py
Modified: zorg/trunk/llvmlab/llvmlab/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/ui/app.py?rev=125891&r1=125890&r2=125891&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/ui/app.py (original)
+++ zorg/trunk/llvmlab/llvmlab/ui/app.py Fri Feb 18 10:42:13 2011
@@ -10,12 +10,16 @@
class App(flask.Flask):
@staticmethod
- def create_standalone(config = None, data = None):
+ def create_standalone(config = None, data = None, config_path = None):
+ if config_path is not None:
+ assert config is None
+ assert data is None
+
# Construct the application.
app = App(__name__)
# Load the application configuration.
- app.load_config(config)
+ app.load_config(config, config_path)
# Load the database.
app.load_data(data)
@@ -51,8 +55,11 @@
def __init__(self, name):
super(App, self).__init__(name)
- def load_config(self, config = None):
- if config is None:
+ def load_config(self, config = None, config_path = None):
+ if config_path is not None:
+ # Load the configuration file.
+ self.config.from_pyfile(os.path.abspath(config_path))
+ elif config is None:
# Load the configuration file.
self.config.from_envvar("LLVMLAB_CONFIG")
else:
@@ -84,6 +91,12 @@
self.config.data = data
+ def save_data(self):
+ file = open(self.config["DATA_PATH"], 'w')
+ flask.json.dump(self.config.data.todata(), file, indent=2)
+ print >>file
+ file.close()
+
def authenticate_login(self, username, password):
passhash = hashlib.sha256(
password + self.config["SECRET_KEY"]).hexdigest()
More information about the llvm-commits
mailing list