37 |
from gnue.common.formatting import GTypecast |
from gnue.common.formatting import GTypecast |
38 |
from gnue.common.datasources import GConditions |
from gnue.common.datasources import GConditions |
39 |
|
|
|
|
|
40 |
######################################################################## |
######################################################################## |
41 |
# |
# |
42 |
# Class that handles DataSources. This is a subclass of GObj, which |
# Class that handles DataSources. This is a subclass of GObj, which |
105 |
except AttributeError: |
except AttributeError: |
106 |
pass |
pass |
107 |
try: |
try: |
108 |
# TODO: This **really** needs to be deprecated and |
# TODO: This might be deprecated; |
109 |
# TODO: should be using <sorting> tags |
# TODO: should be using <sorting> tags |
110 |
for field in string.split(self.order_by,','): |
for field in string.split(self.order_by,','): |
111 |
if field[-5:].lower() == ' desc': |
if field[-5:].lower() == ' desc': |
176 |
self._connections = connectionManager |
self._connections = connectionManager |
177 |
|
|
178 |
def initialize(self): |
def initialize(self): |
179 |
|
print self.name |
180 |
if not self.connection: |
if not self.connection: |
181 |
# We are a connectionless datasource (virtual?) |
# We are a connectionless datasource (virtual?) |
182 |
# We have to bind to something, so bind to empty or static driver |
# We have to bind to something, so bind to empty or static driver |
183 |
if not self.type=="static": |
if not self.type=="static": |
184 |
from gnue.common.datasources.drivers.special.unbound import Driver |
from gnue.common.datasources.drivers.special.unbound import Driver |
185 |
GDebug.printMesg (7, 'Using empty data driver') |
GDebug.printMesg (7, 'Using empty data driver') |
186 |
dataObject = Driver.supportedDataObjects['object']() |
dataObject = Driver.supportedDataObjects['object'](None) |
187 |
|
|
188 |
else: |
else: |
189 |
from gnue.common.datasources.drivers.special.static import Driver |
from gnue.common.datasources.drivers.special.static import Driver |
190 |
GDebug.printMesg (7, 'Using static data driver') |
GDebug.printMesg (7, 'Using static data driver') |
191 |
dataObject = Driver.supportedDataObjects['object']() |
dataObject = Driver.supportedDataObjects['object'](None) |
192 |
|
|
193 |
for child in self._children: |
for child in self._children: |
194 |
if isinstance(child, GStaticSet): |
if isinstance(child, GStaticSet): |
241 |
|
|
242 |
def connect(self): |
def connect(self): |
243 |
if self.connection != None: |
if self.connection != None: |
244 |
self._connections.\ |
self._connections.requestConnection(self._dataObject) |
245 |
requestConnection(self._dataObject, self.connection) |
|
246 |
|
|
247 |
def getDataObject(self): |
def getDataObject(self): |
248 |
return self._dataObject |
return self._dataObject |
249 |
|
|
250 |
|
|
251 |
def referenceField(self, field, defaultValue=None): |
def referenceField(self, field, defaultValue=None): |
252 |
GDebug.printMesg(7,'Field %s implicitly referenced' % field) |
GDebug.printMesg(7,'Field %s implicitly referenced' % field) |
253 |
self._fieldReferences[field] = "" |
self._fieldReferences[field] = "" |
255 |
if defaultValue != None: |
if defaultValue != None: |
256 |
self._defaultValues[field] = defaultValue |
self._defaultValues[field] = defaultValue |
257 |
|
|
258 |
def referenceFields(self, fields): |
def referenceFields(self, fields): |
259 |
for field in fields: |
for field in fields: |
260 |
if (type(field) == types.StringType) or \ |
if type(field) == types.StringType: |
|
(type(field) == types.UnicodeType): |
|
261 |
self.referenceField(field) |
self.referenceField(field) |
262 |
else: |
else: |
263 |
self.referenceField(*field) |
self.referenceField(*field) |
264 |
|
|
265 |
def referenceUnboundField(self, field, defaultValue=None): |
def referenceUnboundField(self, field, defaultValue=None): |
266 |
GDebug.printMesg(7,'Field %s implicitly referenced' % field) |
GDebug.printMesg(7,'Field %s implicitly referenced' % field) |
267 |
self._unboundFieldReferences[field] = 1 |
self._unboundFieldReferences[field] = 1 |
553 |
# Wrapper for standalone DataSources |
# Wrapper for standalone DataSources |
554 |
# (i.e., not in context of a GObj tree) |
# (i.e., not in context of a GObj tree) |
555 |
# |
# |
556 |
def DataSourceWrapper(connections=None, fields=(), attributes={}, init=1): |
def DataSourceWrapper(connections=None, fields=(), attributes={}, init=1, unicodeMode=0): |
557 |
source = _DataSourceWrapper() |
source = _DataSourceWrapper() |
558 |
|
|
559 |
if connections: |
if connections: |