[Fusionforge-commits] r14635 - in trunk: . src/plugins/moinmoin/lib

Roland Mas lolando at fusionforge.org
Fri Oct 14 18:04:53 CEST 2011


Author: lolando
Date: 2011-10-14 18:04:53 +0200 (Fri, 14 Oct 2011)
New Revision: 14635

Modified:
   trunk/
   trunk/src/plugins/moinmoin/lib/fusionforge.py
Log:
Added caching mechanism for configuration values


Modified: trunk/src/plugins/moinmoin/lib/fusionforge.py
===================================================================
--- trunk/src/plugins/moinmoin/lib/fusionforge.py	2011-10-14 16:04:44 UTC (rev 14634)
+++ trunk/src/plugins/moinmoin/lib/fusionforge.py	2011-10-14 16:04:53 UTC (rev 14635)
@@ -18,15 +18,20 @@
 
 class FusionForgeLink():
     def get_config(self, varname, secname='core'):
-        return subprocess.Popen(["/usr/share/gforge/bin/forge_get_config", varname, secname], stdout = subprocess.PIPE).communicate()[0].rstrip('\n')
+        if secname not in self.cachedconfig:
+            self.cachedconfig[secname] = {}
+        if varname not in self.cachedconfig[secname]:
+            self.cachedconfig[secname][varname] = subprocess.Popen(["/usr/share/gforge/bin/forge_get_config", varname, secname], stdout = subprocess.PIPE).communicate()[0].rstrip('\n')
+        return self.cachedconfig[secname][varname]
 
     def __init__(self, cookies=['session_ser'], autocreate=True):
+        self.cachedconfig = {}
         self.database_host = self.get_config('database_host')
         self.database_name = self.get_config('database_name')
         self.database_user = self.get_config('database_user')
         self.database_port = self.get_config('database_port')
         self.database_password = self.get_config('database_password')
-
+        
         if (self.database_host != ''):
             self.conn = psycopg2.connect(database=self.database_name,
                                          user=self.database_user,




More information about the Fusionforge-commits mailing list