[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7814 - trunk/gnue-forms/src/GFObjects
From: |
jamest |
Subject: |
[gnue] r7814 - trunk/gnue-forms/src/GFObjects |
Date: |
Tue, 9 Aug 2005 20:40:24 -0500 (CDT) |
Author: jamest
Date: 2005-08-09 20:40:22 -0500 (Tue, 09 Aug 2005)
New Revision: 7814
Modified:
trunk/gnue-forms/src/GFObjects/GFBlock.py
Log:
added support for : conditionals in a forms query
so that you can query for things like
>:123 which would query for field values greater than 123
supported : conditionals are
>, >=, <, <=, =, !=, like, null, !null
Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py 2005-08-09 23:13:28 UTC (rev
7813)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py 2005-08-10 01:40:22 UTC (rev
7814)
@@ -806,12 +806,44 @@
if no condition is needed.
"""
+ # 'user input': [GCondition, pass value?]
+ comparisons = { '>': ['gt', True],
+ '>=': ['ge', True],
+ '<': ['lt', True],
+ '<=': ['le', True],
+ '=': ['eq', True],
+ '!=': ['ne', True],
+ 'like': ['like', True],
+ 'null': ['null', False],
+ '!null': ['notnull', False],
+ }
+
condLike = {}
condEq = {}
-
+ conditions = []
# Get all the user-supplied parameters from the entry widgets
for entry, val in block._queryValues.items ():
if entry._bound and entry.isQueryable () and len (str (val)):
+
+ splitValue = val.split(':')
+ splitValue[0]=splitValue[0].lower()
+ try:
+ if comparisons[splitValue[0]][1]:
+ conditions.append([ comparisons[splitValue[0]][0],
+ ['field', entry.field],
+ ['const', ':'.join(splitValue[1:])]
+ ])
+ else:
+ conditions.append([ comparisons[splitValue[0]][0],
+ ['field', entry.field]
+ ])
+
+ continue
+ except KeyError:
+ pass
+
+ # Falls through to old behaviour if no : condition given or
+ # the : condition is unknown
if entry.typecast == 'text':
if block._convertAsterisksToPercent:
try:
@@ -829,8 +861,8 @@
epf = [['eq', ['field', f], ['const', v]] for (f, v) in condEq.items ()]
lpf = [['like', ['field', f], ['const', v]] for (f, v) in condLike.items ()]
- if epf or lpf:
- result = GConditions.buildConditionFromPrefix (['and'] + epf + lpf)
+ if epf or lpf or conditions:
+ result = GConditions.buildConditionFromPrefix (['and'] + epf + lpf +
conditions)
else:
result = {}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7814 - trunk/gnue-forms/src/GFObjects,
jamest <=