diff pylons_app/lib/utils.py @ 413:55377fdc1fc6

cleared global application settings. Made it much more extensible by keeping it key/value in the database.
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 01 Aug 2010 18:36:00 +0200
parents a26f48ad7a8a
children a9a607a58b1c
line wrap: on
line diff
--- a/pylons_app/lib/utils.py	Sun Aug 01 17:08:58 2010 +0200
+++ b/pylons_app/lib/utils.py	Sun Aug 01 18:36:00 2010 +0200
@@ -100,13 +100,17 @@
 def get_hg_settings():
     try:
         sa = meta.Session
-        ret = sa.query(HgAppSettings).scalar()
+        ret = sa.query(HgAppSettings).all()
     finally:
         meta.Session.remove()
         
     if not ret:
         raise Exception('Could not get application settings !')
-    return ret
+    settings = {}
+    for each in ret:
+        settings['hg_app_' + each.app_settings_name] = each.app_settings_value    
+    
+    return settings
     
 def make_ui(read_from='file', path=None, checkpaths=True):        
     """
@@ -155,8 +159,9 @@
 
 def set_hg_app_config(config):
     hgsettings = get_hg_settings()
-    config['hg_app_auth_realm'] = hgsettings.app_auth_realm
-    config['hg_app_name'] = hgsettings.app_title
+    
+    for k, v in hgsettings.items():
+        config[k] = v
 
 def invalidate_cache(name, *args):
     """Invalidates given name cache"""