commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r7387 - in trunk/gnue-common/src/datasources: . drivers/Base


From: reinhard
Subject: [gnue] r7387 - in trunk/gnue-common/src/datasources: . drivers/Base
Date: Fri, 15 Apr 2005 18:39:07 -0500 (CDT)

Author: reinhard
Date: 2005-04-15 18:39:06 -0500 (Fri, 15 Apr 2005)
New Revision: 7387

Modified:
   trunk/gnue-common/src/datasources/GDataSource.py
   trunk/gnue-common/src/datasources/drivers/Base/DataObject.py
   trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
   trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
Log:
Changed all datasource weak references from weakref.proxy to weakref.ref
because weakref.proxy can not be tested whether it still is valid or not.


Modified: trunk/gnue-common/src/datasources/GDataSource.py
===================================================================
--- trunk/gnue-common/src/datasources/GDataSource.py    2005-04-15 23:19:07 UTC 
(rev 7386)
+++ trunk/gnue-common/src/datasources/GDataSource.py    2005-04-15 23:39:06 UTC 
(rev 7387)
@@ -276,12 +276,12 @@
       if not self.type=="static":
         from gnue.common.datasources.drivers import Base
         gDebug (7, 'Using empty data driver')
-        dataObject = Base.DataObject (None, weakref.proxy (self))
+        dataObject = Base.DataObject (None, weakref.ref (self))
 
       else:
         from gnue.common.datasources.drivers.special import static
         gDebug (7, 'Using static data driver')
-        dataObject = static.DataObject (None, weakref.proxy (self))
+        dataObject = static.DataObject (None, weakref.ref (self))
 
         for child in self._children:
           if isinstance(child, GStaticSet):
@@ -296,7 +296,7 @@
       # catch this exception and handle it properly (exit w/message)
       dataObject = \
          self._connections.getDataObject (self.connection, self.type,
-             datasource = weakref.proxy (self))
+             datasource = weakref.ref (self))
       gDebug (7, "GDataSource.py bound to %s " % dataObject)
       
       # Check if the connection has a fixed primary key name

Modified: trunk/gnue-common/src/datasources/drivers/Base/DataObject.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/DataObject.py        
2005-04-15 23:19:07 UTC (rev 7386)
+++ trunk/gnue-common/src/datasources/drivers/Base/DataObject.py        
2005-04-15 23:39:06 UTC (rev 7387)
@@ -87,18 +87,18 @@
 
     resultset =  self.__createResultSet (readOnly, masterRecordSet)
 
-    if self.__dataSource.type == 'object':
+    if (self.__dataSource ()).type == 'object':
       resultset.query ('object',
                        table      = self.table,
-                       fieldnames = self.__dataSource._fieldReferences.keys (),
+                       fieldnames = (self.__dataSource 
())._fieldReferences.keys (),
                        condition  = cond,
                        sortorder  = self.sorting and self.sorting or [],
                        distinct   = self.distinct)
 
-    elif self.__dataSource.type == 'static':
+    elif (self.__dataSource ()).type == 'static':
       resultset.query ('static', data = self._staticSet.data)
 
-    elif self.__dataSource.type == 'sql':
+    elif (self.__dataSource ()).type == 'sql':
       resultset.query ('sql', sql = self._rawSQL.getChildrenAsContent ())
 
     return resultset
@@ -113,12 +113,12 @@
 
     return self._resultSetClass (
         dataObject       = self,
-        defaultData      = self.__dataSource._defaultData,
-        connection       = self.__dataSource._connection,
-        rowidField       = self.__dataSource._rowidField,
-        primarykeyFields = self.__dataSource._primarykeyFields,
-        tablename        = self.__dataSource.table,
-        boundFields      = self.__dataSource._fieldReferences.keys (),
+        defaultData      = (self.__dataSource ())._defaultData,
+        connection       = (self.__dataSource ())._connection,
+        rowidField       = (self.__dataSource ())._rowidField,
+        primarykeyFields = (self.__dataSource ())._primarykeyFields,
+        tablename        = (self.__dataSource ()).table,
+        boundFields      = (self.__dataSource ())._fieldReferences.keys (),
         readonly         = readOnly,
         masterRecord     = masterRecord,
         dataSource       = self.__dataSource)

Modified: trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-04-15 
23:19:07 UTC (rev 7386)
+++ trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-04-15 
23:39:06 UTC (rev 7387)
@@ -118,8 +118,8 @@
       for (field, value) in initialData.items ():
         self.__fields [field] = value
 
-      if self.__dataSource is not None:
-        self.__dataSource._onRecordLoaded (self)
+      if self.__dataSource () is not None:
+        (self.__dataSource ())._onRecordLoaded (self)
 
     else:
 
@@ -213,8 +213,8 @@
           self.__status = 'inserted'
         elif self.__status == 'clean':
           self.__status = 'modified'
-        if self.__dataSource is not None:
-          self.__dataSource._onModification (self)
+        if self.__dataSource () is not None:
+          (self.__dataSource ())._onModification (self)
 
   # ---------------------------------------------------------------------------
 
@@ -393,28 +393,28 @@
     status = self.__status
 
     # Call the hooks for commit-level hooks
-    if self.__dataSource is not None:
+    if self.__dataSource () is not None:
       # A trigger code could change the status from empty/inserted/modified to
       # deleted. In that case, both triggers would be called.
       if self.__status in ['empty', 'inserted']:
-        self.__dataSource._beforeCommitInsert (self)
+        (self.__dataSource ())._beforeCommitInsert (self)
       if self.__status == 'modified':
-        self.__dataSource._beforeCommitUpdate (self)
+        (self.__dataSource ())._beforeCommitUpdate (self)
       if self.__status == 'deleted':
-        self.__dataSource._beforeCommitDelete (self)
+        (self.__dataSource ())._beforeCommitDelete (self)
 
       # Check for empty primary key and set with the sequence value if so
       # TODO: Move this to GDataSource
+      ds = self.__dataSource ()
       if self.__status in ['empty', 'inserted']:
-        if hasattr (self.__dataSource, 'primarykey') and \
-            hasattr (self.__dataSource, 'primarykeyseq'):
-          if self.__dataSource.primarykey and \
-              ',' not in self.__dataSource.primarykey and \
-              self.__dataSource.primarykeyseq and \
+        if hasattr (ds, 'primarykey') and \
+            hasattr (ds, 'primarykeyseq'):
+          if ds.primarykey and ',' not in ds.primarykey and \
+              ds.primarykeyseq and \
               hasattr (self.__connection, 'getsequence') and \
-              self.getField (self.__dataSource.primarykey) is None:
-            pk = self.__connection.getsequence 
(self.__dataSource.primarykeyseq)
-            self.setField (self.__dataSource.primarykey, pk)
+              self.getField (ds.primarykey) is None:
+            pk = self.__connection.getsequence (ds.primarykeyseq)
+            self.setField (ds.primarykey, pk)
 
     # If we have a connection (i.e. we aren't static or unbound), do the post
     if self.__connection is not None:
@@ -465,7 +465,7 @@
     """
 
     # First, requery ourselves
-    if self.__dataSource is not None and self.__dataSource.requery:
+    if self.__dataSource () is not None and (self.__dataSource ()).requery:
       if self.__rowidField or self.__primarykeyFields:
         self.__requery (self.__boundFields)
 

Modified: trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-04-15 
23:19:07 UTC (rev 7386)
+++ trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-04-15 
23:39:06 UTC (rev 7387)
@@ -96,7 +96,7 @@
 
     getattr (self, queryfunc) (self.__connection, **kwargs)
 
-    self.__generator = self._fetch (self.__dataSource.cache)
+    self.__generator = self._fetch ((self.__dataSource ()).cache)
 
     # (TODO: could be delayed to first call of getRecordCount)
     self._recordCount = self._count ()
@@ -625,8 +625,8 @@
 
     # Finally, tell everyone who wants to know that we have become a "new
     # ResultSet" (i.e. the complete data should be redisplayed).
-    if self.__dataSource is not None:
-      self.__dataSource.notifyResultSetListeners ()
+    if self.__dataSource () is not None:
+      (self.__dataSource ()).notifyResultSetListeners ()
 
 
   # ---------------------------------------------------------------------------
@@ -643,8 +643,8 @@
 
     self.__generator = None
 
-    if self.__dataSource and self.__dataSource._currentResultSet == self:
-      self.__dataSource.close ()
+    if self.__dataSource () and (self.__dataSource ())._currentResultSet == 
self:
+      (self.__dataSource ()).close ()
     self._dataObject = None
 
     self.__listeners    = []





reply via email to

[Prev in Thread] Current Thread [Next in Thread]