16 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
17 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
18 |
# |
# |
19 |
# Copyright 2000-2002 Free Software Foundation |
# Copyright 2000-2003 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# GFBlock.py |
# GFBlock.py |
57 |
#self._datasource = None |
#self._datasource = None |
58 |
self._resultSet = None |
self._resultSet = None |
59 |
self._dataSourceLink = None |
self._dataSourceLink = None |
|
self._entryList = [] |
|
60 |
|
|
61 |
self._currentRecord = 0 |
self._currentRecord = 0 |
62 |
self._recordCount = 0 |
self._recordCount = 0 |
66 |
self._autocreate = int(gConfig('autocreate')) |
self._autocreate = int(gConfig('autocreate')) |
67 |
self._gap = 0 |
self._gap = 0 |
68 |
self._rows = 1 |
self._rows = 1 |
|
|
|
69 |
self._scrollBars= [] |
self._scrollBars= [] |
70 |
|
|
71 |
|
# Populated by GFEntry's initialize |
72 |
|
self._entryList = [] |
73 |
|
|
74 |
|
# Populated by GFField's initialize |
75 |
|
self._fieldMap = {} |
76 |
|
self._fieldList = [] |
77 |
|
|
78 |
# |
# |
79 |
# Trigger exposure |
# Trigger exposure |
80 |
# |
# |
81 |
self._validTriggers = { |
self._validTriggers = { |
82 |
'ON-SWITCH': 'On-Switch', |
## 'ON-SWITCH': 'On-Switch', ## Deprecated |
83 |
'ON-NEWRECORD': 'On-NewRecord', |
'ON-NEWRECORD': 'On-NewRecord', |
84 |
'PRE-COMMIT': 'Pre-Commit', |
'PRE-COMMIT': 'Pre-Commit', |
85 |
'POST-COMMIT': 'Post-Commit', |
'POST-COMMIT': 'Post-Commit', |
86 |
'POST-QUERY': 'Post-Query', |
'POST-QUERY': 'Post-Query', |
87 |
'PRE-MODIFY': 'Pre-Modify', |
'PRE-MODIFY': 'Pre-Modify', |
88 |
'PRE-INSERT': 'Pre-Insert', |
'PRE-INSERT': 'Pre-Insert', |
89 |
'PRE-DELETE': 'Pre-Delete', |
'PRE-DELETE': 'Pre-Delete', |
91 |
'PRE-FOCUSOUT': 'Pre-FocusOut', |
'PRE-FOCUSOUT': 'Pre-FocusOut', |
92 |
'POST-FOCUSOUT': 'Post-FocusOut', |
'POST-FOCUSOUT': 'Post-FocusOut', |
93 |
'PRE-FOCUSIN': 'Pre-FocusIn', |
'PRE-FOCUSIN': 'Pre-FocusIn', |
94 |
'POST-FOCUSIN': 'Post-FocusIn',} |
'POST-FOCUSIN': 'Post-FocusIn' } |
95 |
|
|
96 |
|
|
97 |
self._triggerGlobal = 1 |
self._triggerGlobal = 1 |
98 |
self._triggerFunctions={'clear':{'function':self.processClear}, |
self._triggerFunctions={'clear':{'function':self.processClear, |
99 |
'gotoRecord':{'function':self.jumpRecord}, |
'description':''}, |
100 |
|
'commit':{'function':self.commit, |
101 |
|
'description':''}, |
102 |
|
'deleteRecord':{'function':self.deleteRecord, |
103 |
|
'description':''}, |
104 |
'getRecordCount':{'function':self.getRecordCount}, |
'getRecordCount':{'function':self.getRecordCount}, |
105 |
'getCurrentRecord':{'function':self.getCurrentRecord}, |
'getCurrentRecord':{'function':self.getCurrentRecord}, |
106 |
'isSaved':{'function':self.isSaved}, |
'getCurrentRecordNumber':{'function':self.getCurrentRecordNumber, |
107 |
'deleteRecord':{'function':self.deleteRecord}, |
'description':''}, |
108 |
'isEmpty':{'function':self.isEmpty}, |
'executeQuery':{'function':self.processQuery, |
109 |
'nextRecord':{'function':self.nextRecord}, |
'description':''}, |
110 |
'lastRecord':{'function':self.lastRecord}, |
'gotoRecord':{'function':self.jumpRecord, |
111 |
'firstRecord':{'function':self.firstRecord}, |
'description':''}, |
112 |
'prevRecord':{'function':self.prevRecord}, |
'firstRecord':{'function':self.firstRecord, |
113 |
'newRecord':{'function':self.newRecord}, |
'description':'Navigates the block to the first record it contains.'}, |
114 |
'initQuery':{'function':self.initQuery}, |
'isEmpty':{'function':self.isEmpty, |
115 |
'processQuery':{'function':self.processQuery}, |
'description':'Returns 1 if block is empty.'}, |
116 |
'commit':{'function':self.commit}, |
'isSaved':{'function':self.isSaved, |
117 |
'processRollback':{'function':self.processRollback}, |
'description':'Returns 1 if block contains no modified records.'}, |
118 |
|
'lastRecord':{'function':self.lastRecord, |
119 |
|
'description':'Navigates the block to the last record it contains.'}, |
120 |
|
'newRecord':{'function':self.newRecord, |
121 |
|
'description':''}, |
122 |
|
'nextRecord':{'function':self.nextRecord, |
123 |
|
'description':'Navigates the block to the next record in sequence.'}, |
124 |
|
'prevRecord':{'function':self.prevRecord, |
125 |
|
'description':'Navigates the block to the previous record in sequence.'}, |
126 |
|
'rollback':{'function':self.processRollback, |
127 |
|
'description':'Clears all records regardless of state from the block'}, |
128 |
|
'initQuery':{'function':self.initQuery, |
129 |
|
'description':'Prepares the block for query input.'}, |
130 |
} |
} |
131 |
|
|
132 |
self._triggerProperties={'parent': {'get':self.getParent}} |
self._triggerProperties={'parent': {'get':self.getParent}} |
133 |
|
|
134 |
def __getitem__(self, index): |
## def __getitem__(self, index): |
135 |
|
## |
136 |
cnt = self._resultSet.getRecordCount() - 1 |
## cnt = self._resultSet.getRecordCount() - 1 |
137 |
if index > cnt: |
## if index > cnt: |
138 |
raise IndexError |
## raise IndexError |
139 |
|
## |
140 |
print "GFBlock", index |
## self.jumpRecord(index) |
141 |
self.jumpRecord(index) |
## |
142 |
|
## if cnt == index and self.isEmpty(): |
143 |
if cnt == index and self.isEmpty(): |
## print "Bad, bad, bad" |
144 |
print "Bad, bad, bad" |
## raise IndexError |
145 |
raise IndexError |
## |
146 |
|
## return self |
|
return self |
|
147 |
|
|
148 |
def _buildObject(self): |
def _buildObject(self): |
149 |
|
|
156 |
if hasattr(self,'datasource'): |
if hasattr(self,'datasource'): |
157 |
self.datasource = string.lower(self.datasource) |
self.datasource = string.lower(self.datasource) |
158 |
|
|
|
self.walk(self.__setChildRowSettings) |
|
159 |
return GFContainer._buildObject(self) |
return GFContainer._buildObject(self) |
160 |
|
|
161 |
# |
# |
163 |
# |
# |
164 |
def initialize(self): |
def initialize(self): |
165 |
self._form = form = self.findParentOfType('GFForm') |
self._form = form = self.findParentOfType('GFForm') |
166 |
self._page = self.findParentOfType('GFPage') |
self._logic = logic = self.findParentOfType('GFLogic') |
167 |
|
|
168 |
form._blockList.append(self) |
logic._blockList.append(self) |
169 |
|
logic._blockMap[self.name] = self |
170 |
|
|
171 |
# Initialize our events system |
# Initialize our events system |
172 |
events.EventAware.__init__(self, self._form._app.eventController) |
events.EventAware.__init__(self, form._instance.eventController) |
173 |
|
|
174 |
# Get all focusable items, ordered correctly |
# Get all focusable items, ordered correctly |
175 |
self._focusOrder = self.getFocusOrder() |
self._focusOrder = self.getFocusOrder() |
176 |
|
|
|
# Find all GFEntry's |
|
|
for object in self._focusOrder: |
|
|
if object._type == 'GFEntry': |
|
|
self._entryList.append(object) |
|
|
|
|
177 |
# Create a stub/non-bound datasource if we aren't bound to one |
# Create a stub/non-bound datasource if we aren't bound to one |
178 |
if not hasattr(self,'datasource') or not self.datasource: |
if not hasattr(self,'datasource') or not self.datasource: |
179 |
ds = GFDataSource(self) |
ds = GFDataSource(self) |
180 |
self.datasource = ds.name = "dts_%s" % self |
self.datasource = ds.name = "dts_%s" % self |
181 |
self._form._datasourceDictionary[ds.name] = ds |
form._datasourceDictionary[ds.name] = ds |
182 |
ds._buildObject() |
ds._buildObject() |
183 |
ds.phaseInit() |
ds.phaseInit() |
184 |
|
|
185 |
self._dataSourceLink = self._form._datasourceDictionary[self.datasource] |
self._dataSourceLink = form._datasourceDictionary[self.datasource] |
186 |
|
|
187 |
# We will monitor our own resultSet changes |
# We will monitor our own resultSet changes |
188 |
self._dataSourceLink.registerResultSetListener(self._loadResultSet) |
self._dataSourceLink.registerResultSetListener(self._loadResultSet) |
189 |
|
|
190 |
|
self.walk(self.__setChildRowSettings) |
191 |
|
|
192 |
def __setChildRowSettings(self, object): |
def __setChildRowSettings(self, object): |
193 |
if hasattr(object,'rows'): |
if hasattr(object,'rows'): |
194 |
object._rows = object.rows |
rows = object._rows = object.rows |
195 |
else: |
else: |
196 |
object._rows = self._rows |
rows = object._rows = self._rows |
197 |
|
|
198 |
if hasattr(object,'rowSpacer'): |
if hasattr(object,'rowSpacer'): |
199 |
object._gap = object.rowSpacer |
object._gap = object.rowSpacer |
200 |
else: |
else: |
201 |
object._gap = self._gap |
object._gap = self._gap |
202 |
|
|
|
|
|
203 |
def getResultSet(self): |
def getResultSet(self): |
204 |
return self._resultSet |
return self._resultSet |
205 |
|
|
206 |
def getCurrentRecord(self): |
def getCurrentRecord(self): |
207 |
return self.getResultSet().getCurrentRecord() |
return self.getResultSet().getCurrentRecord() |
208 |
|
|
209 |
|
def getCurrentRecordNumber(self): |
210 |
|
return self.getResultSet().getRecordNumber() |
211 |
|
|
212 |
def getRecordCount(self): |
def getRecordCount(self): |
213 |
return self._recordCount |
return self._recordCount |
214 |
|
|
215 |
|
|
216 |
# |
# |
217 |
# isSaved |
# isSaved |
218 |
# |
# |
259 |
# Moves the proper record into editing position |
# Moves the proper record into editing position |
260 |
# |
# |
261 |
def switchRecord(self, adjustment): |
def switchRecord(self, adjustment): |
262 |
|
|
263 |
self._currentRecord = self._resultSet.getRecordNumber() |
self._currentRecord = self._resultSet.getRecordNumber() |
264 |
for entry in self._entryList: |
for field in self._fieldList: |
265 |
entry.recalculateVisible( adjustment, self._currentRecord, self._recordCount) |
for entry in field._entryList: |
266 |
self._form.updateUIEntry(entry) |
# This for loop is probably better somewhere else |
267 |
|
entry.recalculateVisible( adjustment, self._currentRecord, self._recordCount) |
268 |
|
self._form.updateUIEntry(field) |
269 |
|
|
270 |
|
|
|
if adjustment <> 0: |
|
|
self.processTrigger('ON-SWITCH') |
|
|
# update the scrollbars... |
|
|
for sb in self._scrollBars: |
|
|
sb.update (self._currentRecord, self._recordCount) |
|
271 |
|
|
272 |
# |
# |
273 |
# newRecord |
# newRecord |
275 |
# Adds a record to the current records in memory |
# Adds a record to the current records in memory |
276 |
# |
# |
277 |
def newRecord(self): |
def newRecord(self): |
278 |
|
|
279 |
|
# Focus out |
280 |
|
self.processTrigger('PRE-FOCUSOUT') |
281 |
|
self.processTrigger('POST-FOCUSOUT') |
282 |
|
|
283 |
if self._resultSet.insertRecord(): |
if self._resultSet.insertRecord(): |
284 |
self._recordCount = self._resultSet.getRecordCount() |
self._recordCount = self._resultSet.getRecordCount() |
285 |
self.switchRecord(1) |
self.switchRecord(1) |
286 |
|
|
287 |
|
# Focus in |
288 |
|
self.processTrigger('PRE-FOCUSIN') |
289 |
self.processTrigger('ON-NEWRECORD') |
self.processTrigger('ON-NEWRECORD') |
290 |
|
self.processTrigger('POST-FOCUSIN') |
291 |
|
|
292 |
def nextRecord(self): |
def nextRecord(self): |
293 |
if self._resultSet.nextRecord(): |
if not self._resultSet.isLastRecord(): |
294 |
|
|
295 |
|
# Do FocusOut triggers |
296 |
|
self.processTrigger('PRE-FOCUSOUT') |
297 |
|
# TODO: I'm not 100% sure of the definition of |
298 |
|
# TODO: Post-FocusOut In this context! |
299 |
|
self.processTrigger('POST-FOCUSOUT') |
300 |
|
|
301 |
|
self._resultSet.nextRecord() |
302 |
self._recordCount = self._resultSet.getRecordCount() |
self._recordCount = self._resultSet.getRecordCount() |
303 |
self.switchRecord(1) |
self.switchRecord(1) |
304 |
|
|
305 |
|
# Focus in |
306 |
|
self.processTrigger('PRE-FOCUSIN') |
307 |
|
self.processTrigger('POST-FOCUSIN') |
308 |
|
|
309 |
elif self._autocreate and not self.isEmpty() and not self.restrictInsert: |
elif self._autocreate and not self.isEmpty() and not self.restrictInsert: |
310 |
self.newRecord() |
self.newRecord() |
311 |
|
# update the scrollbars... |
312 |
|
for sb in self._scrollBars: |
313 |
|
sb.update (self._currentRecord, self._recordCount) |
314 |
|
|
315 |
def lastRecord(self): |
def lastRecord(self): |
316 |
self._resultSet.lastRecord() |
if not self._resultSet.isLastRecord(): |
317 |
self.switchRecord(0) |
# Do FocusOut triggers |
318 |
|
self.processTrigger('PRE-FOCUSOUT') |
319 |
|
self.processTrigger('POST-FOCUSOUT') |
320 |
|
|
321 |
|
self._resultSet.lastRecord() |
322 |
|
self.switchRecord(0) |
323 |
|
|
324 |
|
# Focus in |
325 |
|
self.processTrigger('PRE-FOCUSIN') |
326 |
|
self.processTrigger('POST-FOCUSIN') |
327 |
|
# update the scrollbars... |
328 |
|
for sb in self._scrollBars: |
329 |
|
sb.update (self._currentRecord, self._recordCount) |
330 |
|
|
331 |
def firstRecord(self): |
def firstRecord(self): |
332 |
self._resultSet.firstRecord() |
if not self._resultSet.isFirstRecord(): |
333 |
self.switchRecord(0) |
# Do FocusOut triggers |
334 |
|
self.processTrigger('PRE-FOCUSOUT') |
335 |
|
self.processTrigger('POST-FOCUSOUT') |
336 |
|
|
337 |
|
self._resultSet.firstRecord() |
338 |
|
self.switchRecord(0) |
339 |
|
|
340 |
|
# Focus in |
341 |
|
self.processTrigger('PRE-FOCUSIN') |
342 |
|
self.processTrigger('POST-FOCUSIN') |
343 |
|
# update the scrollbars... |
344 |
|
for sb in self._scrollBars: |
345 |
|
sb.update (self._currentRecord, self._recordCount) |
346 |
|
|
347 |
def prevRecord(self): |
def prevRecord(self): |
348 |
if self._resultSet.prevRecord(): |
if not self._resultSet.isFirstRecord(): |
349 |
|
|
350 |
|
# Do FocusOut triggers |
351 |
|
self.processTrigger('PRE-FOCUSOUT') |
352 |
|
self.processTrigger('POST-FOCUSOUT') |
353 |
|
|
354 |
|
self._resultSet.prevRecord() |
355 |
self.switchRecord(-1) |
self.switchRecord(-1) |
356 |
|
|
357 |
|
# Focus in |
358 |
|
self.processTrigger('PRE-FOCUSIN') |
359 |
|
self.processTrigger('POST-FOCUSIN') |
360 |
|
# update the scrollbars... |
361 |
|
for sb in self._scrollBars: |
362 |
|
sb.update (self._currentRecord, self._recordCount) |
363 |
|
|
364 |
|
def commit(self): |
365 |
|
# self._form.changeFocus(self) |
366 |
|
self._form.commit() |
367 |
|
|
368 |
|
|
369 |
def jumpRecord(self, recordNumber): |
def jumpRecord(self, recordNumber): |
370 |
# If recordNumber is negative, move relative to last record |
# If recordNumber is negative, move relative to last record |
371 |
if recordNumber < 0: |
if recordNumber < 0: |
372 |
recordNumber += self._resultSet.getRecordCount() |
recordNumber += self._resultSet.getRecordCount() |
373 |
if recordNumber < 0: |
if recordNumber < 0: |
374 |
raise "Invalid record number" |
raise "Invalid record number" |
375 |
if not self._resultSet.setRecord(recordNumber): |
if recordNumber != self._resultSet.getRecordNumber(): |
376 |
self._resultSet.lastRecord() |
# Focus out |
377 |
jump = self._resultSet.getRecordNumber() - self._currentRecord |
self.processTrigger('PRE-FOCUSOUT') |
378 |
self._currentRecord = self._resultSet.getRecordNumber() |
self.processTrigger('POST-FOCUSOUT') |
379 |
self.switchRecord(jump) |
|
380 |
|
if not self._resultSet.setRecord(recordNumber): |
381 |
def commit(self): |
self._resultSet.lastRecord() |
382 |
self.getForm().changeFocus(self) |
|
383 |
self.getForm().commit() |
jump = self._resultSet.getRecordNumber() - self._currentRecord |
384 |
|
self._currentRecord = self._resultSet.getRecordNumber() |
385 |
def getForm(self): |
self.switchRecord(jump) |
386 |
return self._form |
|
387 |
|
# Focus in |
388 |
|
self.processTrigger('PRE-FOCUSIN') |
389 |
|
self.processTrigger('POST-FOCUSIN') |
390 |
|
# update the scrollbars... |
391 |
|
for sb in self._scrollBars: |
392 |
|
sb.update (self._currentRecord, self._recordCount) |
393 |
|
|
394 |
# |
# |
395 |
# processCommit |
# processCommit |
396 |
# |
# |
397 |
def processCommit(self): |
def processCommit(self): |
398 |
GDebug.printMesg(1, "processing commit on block %s"%self.name,1) |
GDebug.printMesg(1, "processing commit on block %s"%self.name,1) |
399 |
|
|
400 |
self.mode='commit' |
self.mode='commit' |
401 |
|
|
402 |
self._resultSet.setRecord(self._precommitRecord) |
self._resultSet.setRecord(self._precommitRecord) |
446 |
tmpRecord = self._dataSourceLink.getCurrentResultSet().getCurrentRecord() |
tmpRecord = self._dataSourceLink.getCurrentResultSet().getCurrentRecord() |
447 |
tmpRecord.getFields().update(tmpRecord.getInitialData()) |
tmpRecord.getFields().update(tmpRecord.getInitialData()) |
448 |
tmpRecord.setUpdateFlag(0) |
tmpRecord.setUpdateFlag(0) |
449 |
|
|
450 |
self._dataSourceLink._dataObject.rollback() |
self._dataSourceLink._dataObject.rollback() |
451 |
self.switchRecord(0) |
self.switchRecord(0) |
452 |
|
|
460 |
# If Enter-Query is hit thrice, cancel the query and go into normal mode. |
# If Enter-Query is hit thrice, cancel the query and go into normal mode. |
461 |
|
|
462 |
if self.mode != 'query': |
if self.mode != 'query': |
463 |
for block in self._form._blockList: |
self.mode = 'query' |
464 |
block.mode = 'query' |
self._query2 = int(gConfig("RememberLastQuery")) |
465 |
block._query2 = int(gConfig("RememberLastQuery")) |
self._queryValues = {} |
466 |
block._queryValues = {} |
self._queryValues.update(self._queryDefaults) |
467 |
block._queryValues.update(self._queryDefaults) |
self.switchRecord(0) |
|
block.switchRecord(0) |
|
468 |
elif self._query2: |
elif self._query2: |
469 |
for block in self._form._blockList: |
self._query2 = 0 |
470 |
block._query2 = 0 |
self._queryValues = {} |
471 |
block._queryValues = {} |
self._queryValues.update(self._lastQueryValues) |
472 |
block._queryValues.update(block._lastQueryValues) |
self.switchRecord(0) |
|
block.switchRecord(0) |
|
473 |
else: |
else: |
474 |
for block in self._form._blockList: |
self.mode = 'normal' |
475 |
block.mode = 'normal' |
self.switchRecord(0) |
476 |
block.switchRecord(0) |
|
477 |
|
|
|
|
|
478 |
def processQuery(self): |
def processQuery(self): |
479 |
|
# Set the maxList to a single master block |
480 |
|
# as a placeholder |
481 |
maxList = [self._dataSourceLink._dataObject] |
maxList = [self._dataSourceLink._dataObject] |
482 |
|
while maxList[0]._masterObject: |
483 |
for block in self._form._blockList: |
maxList = [maxList[0]._masterObject] |
484 |
|
|
485 |
|
# Find the longest master/detail chain that |
486 |
|
# contains query values. This will become |
487 |
|
# the chain that is queried |
488 |
|
for block in self._logic._blockList: |
489 |
if block._queryValues.keys(): |
if block._queryValues.keys(): |
490 |
list = [block._dataSourceLink._dataObject] |
templist = [block._dataSourceLink._dataObject] |
491 |
while list[-1]._masterObject: |
while templist[-1]._masterObject: |
492 |
list.append(list[-1]._masterObject) |
templist.append(templist[-1]._masterObject) |
493 |
if len(maxList) < len(list): maxList = list |
if len(maxList) < len(templist): maxList = templist |
494 |
|
|
495 |
|
# Store block states |
496 |
|
for block in self._logic._blockList: |
497 |
|
block.mode = 'normal' |
498 |
|
block._lastQueryValues = {} |
499 |
|
block._lastQueryValues.update(block._queryValues) |
500 |
|
|
501 |
|
# graft in the sloppy query stuff if needed |
502 |
|
for dataobject in maxList: |
503 |
|
for block in self._logic._blockList: |
504 |
|
if dataobject == block._dataSourceLink._dataObject: |
505 |
|
break |
506 |
|
for entry in block._entryList: |
507 |
|
if hasattr(entry._field,'sloppyQuery') and block._queryValues.has_key(entry._field): |
508 |
|
block._queryValues[entry._field] = "%"+ string.join(list(block._queryValues[entry._field]),"%")+"%" |
509 |
|
|
510 |
|
# Build the sql required by the detail blocks |
511 |
SQL = "" |
SQL = "" |
512 |
for dataobject in maxList[:-1]: |
for dataobject in maxList[:-1]: |
513 |
for block in self._form._blockList: |
|
514 |
|
for block in self._logic._blockList: |
515 |
if dataobject == block._dataSourceLink._dataObject: |
if dataobject == block._dataSourceLink._dataObject: |
516 |
break |
break |
517 |
|
|
518 |
|
block.processTrigger('PRE-QUERY') |
519 |
|
for field in block._fieldList: |
520 |
|
field.processTrigger('PRE-QUERY') |
521 |
|
|
522 |
conditions = _generateConditional(block) |
conditions = _generateConditional(block) |
523 |
SQL = self._dataSourceLink.getQueryString(conditions,1,SQL) |
SQL = self._dataSourceLink.getQueryString(conditions,1,SQL) |
524 |
|
|
|
## |
|
|
## TODO: Do we want this anymore? jst |
|
|
## |
|
|
## # Implement sloppyQuery system |
|
|
## if self.mode == 'query': |
|
|
## for entry in self._entryList: |
|
|
## if hasattr(entry,'sloppyQuery'): |
|
|
## newValue = '%' |
|
|
## value = entry._value |
|
|
## for letter in value: |
|
|
## if letter != "%": |
|
|
## newValue += letter+"%" |
|
|
## entry.setValue(newValue) |
|
525 |
|
|
526 |
for block in self._form._blockList: |
for block in self._logic._blockList: |
527 |
if maxList[-1] == block._dataSourceLink._dataObject: |
if maxList[-1] == block._dataSourceLink._dataObject: |
528 |
break |
break |
529 |
rootBlock = block |
rootBlock = block |
530 |
|
|
|
# Store block states |
|
|
for block in self._form._blockList: |
|
|
block.mode = 'normal' |
|
|
block._lastQueryValues = {} |
|
|
block._lastQueryValues.update(block._queryValues) |
|
|
|
|
531 |
conditions = _generateConditional(rootBlock) |
conditions = _generateConditional(rootBlock) |
532 |
rootBlock._dataSourceLink.createResultSet(conditions, sql=SQL) |
rootBlock._dataSourceLink.createResultSet(conditions, sql=SQL) |
533 |
|
|
534 |
rootBlock._recordCount = rootBlock._resultSet.getRecordCount() |
rootBlock._recordCount = rootBlock._resultSet.getRecordCount() |
535 |
|
|
536 |
for block in self._form._blockList: |
for block in self._logic._blockList: |
537 |
block.processTrigger('POST-QUERY') |
block.processTrigger('POST-QUERY') |
538 |
|
for field in block._fieldList: |
539 |
|
field.processTrigger('POST-QUERY') |
540 |
# update the scrollbars... |
# update the scrollbars... |
541 |
for sb in self._scrollBars: |
for sb in self._scrollBars: |
542 |
sb.update (self._currentRecord, self._recordCount) |
sb.update (self._currentRecord, self._recordCount) |
543 |
|
|
544 |
|
|
545 |
def registerScrollBar (self, sb): |
def registerScrollBar (self, sb): |
546 |
self._scrollBars.append (sb) |
self._scrollBars.append (sb) |
547 |
|
|
558 |
GDebug.printMesg(5,'Adding conditional AND (%s=%s)' % (entry.field, block._queryValues[entry])) |
GDebug.printMesg(5,'Adding conditional AND (%s=%s)' % (entry.field, block._queryValues[entry])) |
559 |
conditionEq[entry.field] = block._queryValues[entry] |
conditionEq[entry.field] = block._queryValues[entry] |
560 |
|
|
561 |
if len(conditionLike.keys()) and len(conditionEq.keys()): |
if len(conditionLike.keys()) and len(conditionEq.keys()): |
562 |
GDebug.printMesg(5,'Combining like w/and (%s, %s)' % (conditionLike, conditionEq)) |
GDebug.printMesg(5,'Combining like w/and (%s, %s)' % (conditionLike, conditionEq)) |
563 |
conditions = GConditions.combineConditions( \ |
conditions = GConditions.combineConditions( \ |
564 |
GConditions.buildConditionFromDict(conditionLike, GConditions.GClike), \ |
GConditions.buildConditionFromDict(conditionLike, GConditions.GClike), \ |
565 |
GConditions.buildConditionFromDict(conditionEq, GConditions.GCeq) ) |
GConditions.buildConditionFromDict(conditionEq, GConditions.GCeq) ) |
566 |
|
|
567 |
elif len(conditionLike.keys()): |
elif len(conditionLike.keys()): |
568 |
conditions = GConditions.buildConditionFromDict(conditionLike, GConditions.GClike) |
conditions = GConditions.buildConditionFromDict(conditionLike, GConditions.GClike) |
569 |
|
|
570 |
elif len(conditionEq.keys()): |
elif len(conditionEq.keys()): |
571 |
conditions = GConditions.buildConditionFromDict(conditionEq, GConditions.GCeq) |
conditions = GConditions.buildConditionFromDict(conditionEq, GConditions.GCeq) |
572 |
|
|
573 |
else: |
else: |
574 |
conditions = {} |
conditions = {} |
575 |
|
|
576 |
return conditions |
return conditions |
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|