dabo Commit
Revision 3949
Date: 2008-03-10 14:31:38 -0700 (Mon, 10 Mar 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/3949

Changed:
U   trunk/dabo/db/dCursorMixin.py

Log:
Added caching of the info returned by getFields() on a per table and per SQL 
basis. IOW, as long as the table and the SQL remains the same, getFields will 
not requery the back end.



Diff:
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py       2008-03-08 17:35:41 UTC (rev 3948)
+++ trunk/dabo/db/dCursorMixin.py       2008-03-10 21:31:38 UTC (rev 3949)
@@ -29,6 +29,7 @@
 class dCursorMixin(dObject):
        """Dabo's cursor class, representing the lowest tier."""
        _call_initProperties = False
+       
        def __init__(self, sql="", *args, **kwargs):
                self._convertStrToUnicode = True
                self._initProperties()
@@ -58,6 +59,8 @@
                self._blank = {}
                # Flag for indicating NULL default values were set
                self._nullDefaults = False
+               # Holds the result of getFields() for each table/sql 
combination.
+               self._fieldStructure = {}
                # Writable version of the dbapi 'description' attribute
                self.descriptionClean = None
                # Last executed sql params
@@ -693,16 +696,8 @@
                dataStructure = getattr(self, "_dataStructure", None)
                if dataStructure is not None:
                        # Use the explicitly-set DataStructure to find the 
NonUpdateFields.
-                       nonUpdateFieldAliases = []
-                       realFields = [f[0] for f in self.getFields()]
-                       for field in dataStructure:
-                               field_alias = field[0]
-                               table_name = field[3]
-                               if table_name != self.Table:
-                                       
nonUpdateFieldAliases.append(field_alias)
-                               elif field_alias not in realFields:
-                                       
nonUpdateFieldAliases.append(field_alias)
-                       self.__nonUpdateFields = nonUpdateFieldAliases
+                       self.__nonUpdateFields = [f[0] for f in 
self.DataStructure
+                                       if (f[3] != self.Table) or not f[4]]
                else:
                        # Create the _dataStructure attribute
                        self._getDataStructure()
@@ -1787,7 +1782,14 @@
                if tableName is None:
                        # Use the default
                        tableName = self.Table
-               return self.BackendObject.getFields(tableName, self.AuxCursor)
+               key = "%s:::%s" % (tableName, self.CurrentSQL)
+               try:
+                       return self._fieldStructure[key]
+               except KeyError:
+                       flds = self.BackendObject.getFields(tableName, 
self.AuxCursor)
+                       self._fieldStructure[key] = flds
+                       return flds
+               return 
 
 
        def getFieldInfoFromDescription(self):




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]

Reply via email to