dabo Commit
Revision 6724
Date: 2011-07-17 06:23:23 -0700 (Sun, 17 Jul 2011)
Author: Jacekk
Trac: http://trac.dabodev.com/changeset/6724
Changed:
U trunk/dabo/lib/datanav/Page.py
U trunk/dabo/lib/datanav/__init__.py
U trunk/ide/wizards/AppWizard/spec-PagSelectBase.py.txt
Log:
Added enumerator for query option equivalents, to keep all strings in one place.
Diff:
Modified: trunk/dabo/lib/datanav/Page.py
===================================================================
--- trunk/dabo/lib/datanav/Page.py 2011-07-13 10:24:02 UTC (rev 6723)
+++ trunk/dabo/lib/datanav/Page.py 2011-07-17 13:23:23 UTC (rev 6724)
@@ -7,14 +7,10 @@
from dabo.dLocalize import _, n_
from dabo.dObject import dObject
from dabo.lib.utils import ustr
-
from dabo.ui import dPanel
+from . import QRY_OPERATOR
import Grid
-IGNORE_STRING, CHOICE_TRUE, CHOICE_FALSE = (n_("-ignore-"),
- n_("Is True"),
- n_("Is False"))
-
ASC, DESC = (n_("asc"), n_("desc"))
# Controls for the select page:
@@ -45,12 +41,12 @@
def onValueChanged(self, evt):
# italicize if we are ignoring the field:
- self.FontItalic = (_(IGNORE_STRING) in self.Value)
+ self.FontItalic = (QRY_OPERATOR.IGNORE in self.Value)
if self.Target:
self.Target.FontItalic = self.FontItalic
def onChoiceMade(self, evt):
- if _(IGNORE_STRING) not in self.StringValue:
+ if QRY_OPERATOR.IGNORE not in self.StringValue:
# A comparison op was selected; let 'em enter a value
self.Target.setFocus()
@@ -290,13 +286,13 @@
opVal = self.selectFields[fld]["op"].Value
opStr = opVal
- if not _(IGNORE_STRING) in opVal:
+ if not QRY_OPERATOR.IGNORE in opVal:
fldType = self.selectFields[fld]["type"]
ctrl = self.selectFields[fld]["ctrl"]
if fldType == "bool":
# boolean fields won't have a control;
opVal will
# be either 'Is True' or 'Is False'
- matchVal = (opVal == _(CHOICE_TRUE))
+ matchVal = (opVal == QRY_OPERATOR.TRUE)
elif callable(ctrl):
try:
matchVal = ctrl()
@@ -312,10 +308,10 @@
useStdFormat = True
if fldType in ("char", "memo"):
- if opVal.lower() in (_("equals"),
_("is")):
+ if opVal in (QRY_OPERATOR.EQUAL,
QRY_OPERATOR.IS):
opStr = "="
matchStr =
biz.escQuote(matchVal)
- elif opVal.lower() == _("matches
words"):
+ elif opVal == QRY_OPERATOR.MATCH:
useStdFormat = False
whrMatches = []
for word in matchVal.split():
@@ -328,7 +324,7 @@
opStr = "LIKE"
if matchVal is None:
matchStr =
biz.escQuote("null")
- elif opVal[:1] == "B":
+ elif opVal ==
QRY_OPERATOR.BEGINS:
matchStr =
biz.escQuote(matchVal + "%")
else:
matchStr =
biz.escQuote("%" + matchVal + "%")
@@ -341,15 +337,15 @@
else:
dt = matchVal
matchStr = biz.formatDateTime(dt)
- if opVal.lower() in (_("equals"),
_("is")):
+ if opVal in (QRY_OPERATOR.EQUAL,
QRY_OPERATOR.IS):
opStr = "="
- elif opVal.lower() == _("on or before"):
+ elif opVal == QRY_OPERATOR.ONBEFORE:
opStr = "<="
- elif opVal.lower() == _("on or after"):
+ elif opVal == QRY_OPERATOR.ONAFTER:
opStr = ">="
- elif opVal.lower() == _("before"):
+ elif opVal == QRY_OPERATOR.BEFORE:
opStr = "<"
- elif opVal.lower() == _("after"):
+ elif opVal == QRY_OPERATOR.AFTER:
opStr = ">"
elif fldType in ("int", "float"):
@@ -362,20 +358,20 @@
whrMatches.append(biz.getWordMatchFormat() % mtch)
if len(whrMatches) > 0:
whr = "(" + " or
".join(whrMatches) + ")"
- if opVal.lower() in (_("equals"),
_("is")):
+ if opVal in (QRY_OPERATOR.EQUAL,
QRY_OPERATOR.IS):
opStr = "="
- elif opVal.lower() == _("less
than/equal to"):
+ elif opVal == QRY_OPERATOR.LESSEQUAL:
opStr = "<="
- elif opVal.lower() == _("greater
than/equal to"):
+ elif opVal == QRY_OPERATOR.GREATEREQUAL:
opStr = ">="
- elif opVal.lower() == _("less than"):
+ elif opVal == QRY_OPERATOR.LESS:
opStr = "<"
- elif opVal.lower() == _("greater than"):
+ elif opVal == QRY_OPERATOR.GREATER:
opStr = ">"
elif fldType == "bool":
opStr = "="
- if opVal == _(CHOICE_TRUE):
+ if opVal == QRY_OPERATOR.TRUE:
matchStr = "True"
else:
matchStr = "False"
@@ -425,7 +421,7 @@
opVal =
self.selectFields[vField]["op"].Value
ctrl = self.selectFields[vField]["ctrl"]
- if not _(IGNORE_STRING) in opVal:
+ if not QRY_OPERATOR.IGNORE in opVal:
bizobj.filter(vField,
ctrl.Value, opVal.lower())
if ret:
@@ -440,29 +436,29 @@
wordSearch = bool(int(wordSearch))
if typ in ("char", "memo"):
if typ == "char":
- chcList = [_("Equals"),
- _("Begins With"),
- _("Contains")]
+ chcList = (QRY_OPERATOR.EQUAL,
+ QRY_OPERATOR.BEGINS,
+ QRY_OPERATOR.CONTAINS)
elif typ == "memo":
- chcList = [_("Begins With"),
- _("Contains")]
+ chcList = (QRY_OPERATOR.BEGINS,
+ QRY_OPERATOR.CONTAINS)
if wordSearch:
- chcList.append(_("Matches Words"))
+ chcList.append(QRY_OPERATOR.MATCH)
chc = tuple(chcList)
elif typ in ("date", "datetime"):
- chc = (_("Equals"),
- _("On or Before"),
- _("On or After"),
- _("Before"),
- _("After"))
+ chc = (QRY_OPERATOR.EQUAL,
+ QRY_OPERATOR.ONBEFORE,
+ QRY_OPERATOR.ONAFTER,
+ QRY_OPERATOR.BEFORE,
+ QRY_OPERATOR.AFTER)
elif typ in ("int", "float", "decimal"):
- chc = (_("Equals"),
- _("Greater than"),
- _("Greater than/Equal to"),
- _("Less than"),
- _("Less than/Equal to"))
+ chc = (QRY_OPERATOR.EQUAL,
+ QRY_OPERATOR.GREATER,
+ QRY_OPERATOR.GREATEREQUAL,
+ QRY_OPERATOR.LESS,
+ QRY_OPERATOR.LESSEQUAL)
elif typ == "bool":
- chc = (_(CHOICE_TRUE), _(CHOICE_FALSE))
+ chc = (QRY_OPERATOR.TRUE, QRY_OPERATOR.FALSE)
else:
dabo.log.error(_("Type '%s' not recognized.") % typ)
chc = ()
@@ -595,6 +591,7 @@
def _getDS(self):
return self._dataSource
+
def _setDS(self, val):
self._dataSource = val
if not self.itemsCreated:
Modified: trunk/dabo/lib/datanav/__init__.py
===================================================================
--- trunk/dabo/lib/datanav/__init__.py 2011-07-13 10:24:02 UTC (rev 6723)
+++ trunk/dabo/lib/datanav/__init__.py 2011-07-17 13:23:23 UTC (rev 6724)
@@ -1,8 +1,33 @@
# -*- coding: utf-8 -*-
+from dabo.dLocalize import _
+
+class QRY_OPERATOR:
+ __slots__ = ()
+ AFTER = _("After")
+ BEFORE = _("Before")
+ BEGINS = _("Begins With")
+ BETWEEN = _("Between")
+ CONTAINS = _("Contains")
+ EQUAL = _("Equals")
+ FALSE = _("Is False")
+ GREATER = _("Greater than")
+ GREATEREQUAL = _("Greater than/Equal to")
+ IGNORE = _("-ignore-")
+ IS = _("Is")
+ LESS = _("Less than")
+ LESSEQUAL = _("Less than/Equal to")
+ MATCH = _("Matches Words")
+ ONBEFORE = _("On or Before")
+ ONAFTER = _("On or After")
+ TRUE = _("Is True")
+
+# To achieve compatibility with existing code.
+IGNORE_STRING = QRY_OPERATOR.IGNORE
+
from Form import Form
from Grid import Grid
from Page import Page, SelectPage, EditPage, BrowsePage, SortLabel
-from Page import IGNORE_STRING, SelectionOpDropdown
+from Page import SelectionOpDropdown
from PageFrame import PageFrameMixin, PageFrame
from Bizobj import Bizobj
Modified: trunk/ide/wizards/AppWizard/spec-PagSelectBase.py.txt
===================================================================
--- trunk/ide/wizards/AppWizard/spec-PagSelectBase.py.txt 2011-07-13
10:24:02 UTC (rev 6723)
+++ trunk/ide/wizards/AppWizard/spec-PagSelectBase.py.txt 2011-07-17
13:23:23 UTC (rev 6724)
@@ -5,7 +5,7 @@
import dabo.dEvents as dEvents
import dabo.lib.datanav as datanav
-IGNORE_STRING = datanav.IGNORE_STRING
+IGNORE_STRING = datanav.QRY_OPERATOR.IGNORE
# Controls for the select page:
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]