[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8570 - in branches/forms-0.5/src: . GFObjects
From: |
johannes |
Subject: |
[gnue] r8570 - in branches/forms-0.5/src: . GFObjects |
Date: |
Fri, 18 Aug 2006 03:34:24 -0500 (CDT) |
Author: johannes
Date: 2006-08-18 03:34:23 -0500 (Fri, 18 Aug 2006)
New Revision: 8570
Modified:
branches/forms-0.5/src/GFConfig.py
branches/forms-0.5/src/GFObjects/GFBlock.py
branches/forms-0.5/src/GFObjects/GFField.py
branches/forms-0.5/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: branches/forms-0.5/src/GFConfig.py
===================================================================
--- branches/forms-0.5/src/GFConfig.py 2006-08-18 07:35:46 UTC (rev 8569)
+++ branches/forms-0.5/src/GFConfig.py 2006-08-18 08:34:23 UTC (rev 8570)
@@ -395,4 +395,12 @@
'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: branches/forms-0.5/src/GFObjects/GFBlock.py
===================================================================
--- branches/forms-0.5/src/GFObjects/GFBlock.py 2006-08-18 07:35:46 UTC (rev
8569)
+++ branches/forms-0.5/src/GFObjects/GFBlock.py 2006-08-18 08:34:23 UTC (rev
8570)
@@ -957,10 +957,14 @@
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]
@@ -984,27 +988,69 @@
val = ("%s" % val).replace ('*', '%')
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 +
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
+
+
class _BlockIter:
"""A simple resultset iterator that lets you use ResultSets as:
Modified: branches/forms-0.5/src/GFObjects/GFField.py
===================================================================
--- branches/forms-0.5/src/GFObjects/GFField.py 2006-08-18 07:35:46 UTC (rev
8569)
+++ branches/forms-0.5/src/GFObjects/GFField.py 2006-08-18 08:34:23 UTC (rev
8570)
@@ -116,9 +116,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,
@@ -557,12 +554,6 @@
def triggerGetMaxLength(self):
return self.maxLength
- def triggerSetIgnoreCaseOnQuery(self, value):
- self.ignoreCaseOnQuery = not not value # Force boolean
-
- def triggerGetIgnoreCaseOnQuery(self):
- return self.ignoreCaseOnQuery
-
def triggerSetCase(self, value):
assert (value in ('mixed','upper','lower'))
self.case = value
Modified: branches/forms-0.5/src/GFParser.py
===================================================================
--- branches/forms-0.5/src/GFParser.py 2006-08-18 07:35:46 UTC (rev 8569)
+++ branches/forms-0.5/src/GFParser.py 2006-08-18 08:34:23 UTC (rev 8570)
@@ -461,12 +461,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] r8570 - in branches/forms-0.5/src: . GFObjects,
johannes <=