[Checkins] SVN: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py defer introspection for dependent tables until it is really

Andreas Jung andreas at andreas-jung.com
Sat Mar 17 12:37:27 EDT 2007


Log message for revision 73301:
  defer introspection for dependent tables until it is really
  needed (only when using 'autodetect_relations')
  

Changed:
  U   z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py

-=-
Modified: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py
===================================================================
--- z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py	2007-03-17 16:32:01 UTC (rev 73300)
+++ z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py	2007-03-17 16:37:26 UTC (rev 73301)
@@ -73,18 +73,8 @@
     def getMapper(self, name, schema='public'):
         """ return a (cached) mapper class for a given table 'name' """
 
-        if self._dependent_tables is None:
-            # introspect table dependencies once
-
-            if hasattr(self._wrapper, 'findDependentTables'):
-                self._dependent_tables = self._wrapper.findDependentTables(ignoreErrors=True)
-            else:
-                self._dependent_tables = {}
-
-
         if not self.has_key(name):
 
-
             # no-cached data, let's lookup the table ourselfs
             table = None
 
@@ -112,6 +102,16 @@
                 if self._model[name].get('relations') != None:
                     dependent_table_names = self._model[name].get('relations', []) or []
                 elif self._model[name].get('autodetect_relations', False) == True:
+
+                    if self._dependent_tables is None:
+                        # Introspect table dependencies once. The introspection
+                        # is deferred until the moment where we really need to 
+                        # introspect them
+                        if hasattr(self._wrapper, 'findDependentTables'):
+                            self._dependent_tables = self._wrapper.findDependentTables(ignoreErrors=True)
+                        else:
+                            self._dependent_tables = {}
+
                     dependent_table_names = self._dependent_tables.get(name, []) or []
                 
             # build additional property dict for mapper



More information about the Checkins mailing list