[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8571 - in trunk/gnue-forms/src: . GFObjects
From: |
johannes |
Subject: |
[gnue] r8571 - in trunk/gnue-forms/src: . GFObjects |
Date: |
Fri, 18 Aug 2006 03:38:39 -0500 (CDT) |
Author: johannes
Date: 2006-08-18 03:38:38 -0500 (Fri, 18 Aug 2006)
New Revision: 8571
Modified:
trunk/gnue-forms/src/GFConfig.py
trunk/gnue-forms/src/GFObjects/GFBlock.py
trunk/gnue-forms/src/GFObjects/GFField.py
trunk/gnue-forms/src/GFParser.py
Log:
Introduced a working version of 'query_casesensitive' (per field) as
well as a 'fake_ascii_query' config option to fade out 8-bit characters
in queryies.
Modified: trunk/gnue-forms/src/GFConfig.py
===================================================================
--- trunk/gnue-forms/src/GFConfig.py 2006-08-18 08:34:23 UTC (rev 8570)
+++ trunk/gnue-forms/src/GFConfig.py 2006-08-18 08:38:38 UTC (rev 8571)
@@ -413,4 +413,10 @@
'Typecast' : GTypecast.boolean,
'Default' : True },
+ { 'Name' : 'fake_ascii_query',
+ 'Type' : 'Setting',
+ 'Comment' : 'Change all non-ASCII-characters in a query into a "_"',
+ 'Description': 'Change all non-ASCII-characters in a query into a "_"',
+ 'Typecast' : GTypecast.boolean,
+ 'Default' : False },
)
Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py 2006-08-18 08:34:23 UTC (rev
8570)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py 2006-08-18 08:38:38 UTC (rev
8571)
@@ -1142,7 +1142,6 @@
return self.autoNextRecord
-
# -----------------------------------------------------------------------------
# Create a condition tree for a given block
# -----------------------------------------------------------------------------
@@ -1186,15 +1185,19 @@
value=val[2+len(comparison):]
if baseComparisons[comparison][1]:
- conditions.append([ baseComparisons[comparison][0],
- ['field', entry.field],
- ['const', value]
- ])
+ field = ['field', entry.field]
+ const = ['const', value]
+
+ if not entry.query_casesensitive:
+ field = ['upper', field]
+ const = ['upper', const]
+
+ conditions.append([baseComparisons[comparison][0], field, const])
else:
- conditions.append([ baseComparisons[comparison][0],
- ['field', entry.field]
+ conditions.append([ baseComparisons[comparison][0],
+ ['field', entry.field]
])
- match = True
+ match = True
break
if not match and isinstance(val, bool) and not val:
@@ -1202,6 +1205,7 @@
['eq', ['field', entry.field], ['const', val]],
['null', ['field', entry.field]]])
match = True
+
# Falls through to old behaviour if no : condition given or
# the : condition is unknown
@@ -1213,26 +1217,68 @@
except ValueError:
pass
+ val = cond_value(val)
+
if (val.find ('%') >= 0 or val.find ('_') >= 0):
- condLike [entry.field] = val
+ condLike [entry] = val
else:
- condEq [entry.field] = val
+ condEq [entry] = val
else:
- condEq [entry.field] = val
+ condEq [entry] = val
- epf = [['eq', ['field', f], ['const', v]] for (f, v) in condEq.items ()]
- lpf = [['like', ['field', f], ['const', v]] for (f, v) in condLike.items ()]
+ epf = []
+ for (entry, value) in condEq.items():
+ field = ['field', entry.field]
+ const = ['const', value]
+ if not entry.query_casesensitive:
+ field = ['upper', field]
+ const = ['upper', const]
+
+ epf.append(['eq', field, const])
+
+ lpf = []
+ for (entry, value) in condLike.items():
+ field = ['field', entry.field]
+ const = ['const', value]
+
+ if not entry.query_casesensitive:
+ field = ['upper', field]
+ const = ['upper', const]
+
+ epf.append(['like', field, const])
+
if epf or lpf or conditions:
- result = GConditions.buildConditionFromPrefix (['and'] + epf +
+ result = GConditions.buildConditionFromPrefix (['and'] + epf +
lpf + conditions)
-
else:
result = {}
return result
+# -----------------------------------------------------------------------------
+# Change a condition value as needed
+# -----------------------------------------------------------------------------
+def cond_value(value):
+ """
+ Change a given condition value as needed. If it is a string and the option
+ 'fake_ascii_query' is set, all characters above 127 are changed into an
+ underscore.
+ """
+
+ if isinstance(value, basestring) and gConfigForms('fake_ascii_query'):
+ result = ''
+ for char in value:
+ if ord(char) > 127:
+ char = '_'
+ result += char
+
+ value = result
+
+ return value
+
+
# =============================================================================
# Iterator class for a given GFBlock
# =============================================================================
Modified: trunk/gnue-forms/src/GFObjects/GFField.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFField.py 2006-08-18 08:34:23 UTC (rev
8570)
+++ trunk/gnue-forms/src/GFObjects/GFField.py 2006-08-18 08:38:38 UTC (rev
8571)
@@ -132,8 +132,6 @@
'get': self.triggerGetMinLength },
'editable': {'set': self.triggerSetEditable,
'get': self.triggerGetEditable },
- 'ignoreCaseOnQuery': {'set': self.triggerSetIgnoreCaseOnQuery,
- 'get': self.triggerGetIgnoreCaseOnQuery },
'case': {'set': self.triggerSetCase,
'get': self.triggerGetCase },
'default': {'set': self.triggerSetDefault,
@@ -614,18 +612,6 @@
# -------------------------------------------------------------------------
- def triggerSetIgnoreCaseOnQuery(self, value):
-
- self.ignoreCaseOnQuery = bool(value)
-
- # -------------------------------------------------------------------------
-
- def triggerGetIgnoreCaseOnQuery(self):
-
- return self.ignoreCaseOnQuery
-
- # -------------------------------------------------------------------------
-
def triggerSetCase(self, value):
if value in ('mixed','upper','lower'):
Modified: trunk/gnue-forms/src/GFParser.py
===================================================================
--- trunk/gnue-forms/src/GFParser.py 2006-08-18 08:34:23 UTC (rev 8570)
+++ trunk/gnue-forms/src/GFParser.py 2006-08-18 08:38:38 UTC (rev 8571)
@@ -609,12 +609,13 @@
'the query mask is rewritten with % between '
'each character. Thus {example} would be '
'queried as {%e%x%a%m%p%l%e%}' },
- 'ignoreCaseOnQuery': {
+ 'query_casesensitive': {
'Typecast': GTypecast.boolean,
- 'Label': _('Ignore Case on Queries'),
+ 'Label': _('Perform queries case-sensitive'),
'Default': False,
- 'Description': 'If "Y", the entry widget ignores the case '
- 'of the information entered into the query
mask.' },
+ 'Description': 'If "N", the entry widget ignores the case '
+ 'of the information entered into the query
mask.'
+ },
'editable': {
'Description': 'Only allow this object to be edited if it '
'is currently empty.',
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8571 - in trunk/gnue-forms/src: . GFObjects,
johannes <=