[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7386 - in trunk/gnue-common/src/datasources: . drivers/Base
From: |
reinhard |
Subject: |
[gnue] r7386 - in trunk/gnue-common/src/datasources: . drivers/Base |
Date: |
Fri, 15 Apr 2005 18:19:08 -0500 (CDT) |
Author: reinhard
Date: 2005-04-15 18:19:07 -0500 (Fri, 15 Apr 2005)
New Revision: 7386
Modified:
trunk/gnue-common/src/datasources/GConnections.py
trunk/gnue-common/src/datasources/GDataSource.py
trunk/gnue-common/src/datasources/drivers/Base/DataObject.py
trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
Log:
Made the datasource reference in DataObject a private weak reference. This
solves a few circular reference problems.
Modified: trunk/gnue-common/src/datasources/GConnections.py
===================================================================
--- trunk/gnue-common/src/datasources/GConnections.py 2005-04-15 22:44:44 UTC
(rev 7385)
+++ trunk/gnue-common/src/datasources/GConnections.py 2005-04-15 23:19:07 UTC
(rev 7386)
@@ -285,7 +285,7 @@
#
# Return a database provider object
#
- def getDataObject(self, connection_name, connection_type):
+ def getDataObject(self, connection_name, connection_type, datasource = None):
# This will throw a GConnections.NotFoundError if an unknown
# connection name is specified. The calling method should
@@ -293,7 +293,8 @@
connection = self.getConnection(connection_name)
try:
- dd = connection.supportedDataObjects[connection_type](connection)
+ dd = connection.supportedDataObjects[connection_type](connection,
+ datasource)
gDebug (7, 'Attaching to %s (%s)' \
% (dd.__class__.__name__, connection_type))
return dd
Modified: trunk/gnue-common/src/datasources/GDataSource.py
===================================================================
--- trunk/gnue-common/src/datasources/GDataSource.py 2005-04-15 22:44:44 UTC
(rev 7385)
+++ trunk/gnue-common/src/datasources/GDataSource.py 2005-04-15 23:19:07 UTC
(rev 7386)
@@ -27,6 +27,7 @@
import cStringIO
import string
import types
+import weakref
from gnue.common.apps import errors
from gnue.common.definitions import GObjects, GParser, GParserHelpers
@@ -275,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)
+ dataObject = Base.DataObject (None, weakref.proxy (self))
else:
from gnue.common.datasources.drivers.special import static
gDebug (7, 'Using static data driver')
- dataObject = static.DataObject(None)
+ dataObject = static.DataObject (None, weakref.proxy (self))
for child in self._children:
if isinstance(child, GStaticSet):
@@ -294,7 +295,8 @@
# connection name is specified. The calling method should
# catch this exception and handle it properly (exit w/message)
dataObject = \
- self._connections.getDataObject(self.connection, self.type)
+ self._connections.getDataObject (self.connection, self.type,
+ datasource = weakref.proxy (self))
gDebug (7, "GDataSource.py bound to %s " % dataObject)
# Check if the connection has a fixed primary key name
@@ -320,7 +322,6 @@
dataObject._fieldReferences = self._fieldReferences
dataObject._unboundFieldReferences = self._unboundFieldReferences
dataObject._defaultData = self._defaultData
- dataObject._dataSource = self
hasRaw = False
for child in self._children:
@@ -587,11 +588,6 @@
def close (self):
- # If we have a dataObject available, make sure it's reference to the
- # datasource will be cleared, so garbage collection can do it's job
- if self._dataObject is not None:
- self._dataObject._dataSource = None
-
self._dataObject = None
# Make sure we leave no unreachable reference !
Modified: trunk/gnue-common/src/datasources/drivers/Base/DataObject.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/DataObject.py
2005-04-15 22:44:44 UTC (rev 7385)
+++ trunk/gnue-common/src/datasources/drivers/Base/DataObject.py
2005-04-15 23:19:07 UTC (rev 7386)
@@ -38,8 +38,10 @@
_resultSetClass = ResultSet
- def __init__(self, connection):
+ def __init__(self, connection, dataSource):
+
self._connection = connection
+ self.__dataSource = dataSource
self.table = None
self.distinct = False
@@ -85,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._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
@@ -111,15 +113,15 @@
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)
+ dataSource = self.__dataSource)
# Add a detail data object. This dataobject will create a new resultset
Modified: trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-04-15
22:44:44 UTC (rev 7385)
+++ trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-04-15
23:19:07 UTC (rev 7386)
@@ -24,7 +24,6 @@
__all__ = ['ResultSet']
import string
-import weakref
from gnue.common.datasources import Exceptions
@@ -60,12 +59,8 @@
self.__boundFields = boundFields
self.__readonly = readonly
self.__masterRecord = masterRecord
+ self.__dataSource = dataSource # This is already a weakref!
- if dataSource is not None:
- self.__dataSource = weakref.proxy (dataSource)
- else:
- self.__dataSource = None
-
self._cachedRecords = []
self._currentRecord = -1
self._recordCount = 0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7386 - in trunk/gnue-common/src/datasources: . drivers/Base,
reinhard <=