dabo Commit
Revision 4461
Date: 2008-08-27 09:32:20 -0700 (Wed, 27 Aug 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4461
Changed:
U trunk/dabo/db/__init__.py
U trunk/dabo/db/dBackend.py
U trunk/dabo/db/dCursorMixin.py
U trunk/dabo/db/dDataSet.py
U trunk/dabo/db/dbMySQL.py
U trunk/dabo/lib/reportUtils.py
U trunk/dabo/lib/reportWriter.py
U trunk/dabo/ui/uiwx/dControlItemMixin.py
U trunk/dabo/ui/uiwx/dFont.py
U trunk/dabo/ui/uiwx/dSearchBox.py
U trunk/dabo/ui/uiwx/dSlidePanelControl.py
U trunk/dabo/ui/uiwx/dTextBox.py
U trunk/dabo/ui/uiwx/dTextBoxMixin.py
Log:
Removed all of the code that conditionally imports the decimal module. As we no
longer support Python 2.3, this code is no longer needed.
Diff:
Modified: trunk/dabo/db/__init__.py
===================================================================
--- trunk/dabo/db/__init__.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/db/__init__.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -28,10 +28,7 @@
# TODO: Currently, the logic for building a dictcursor mixin is inside
# dabo.biz.dBiz. I think this logic should be here in dabo.db.
import datetime
-try:
- from decimal import Decimal
-except ImportError:
- Decimal = float
+from decimal import Decimal
from dConnection import dConnection
from dCursorMixin import dCursorMixin
from dConnectInfo import dConnectInfo
Modified: trunk/dabo/db/dBackend.py
===================================================================
--- trunk/dabo/db/dBackend.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/db/dBackend.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -8,10 +8,7 @@
from dabo.dObject import dObject
from dabo.db import dTable
from dNoEscQuoteStr import dNoEscQuoteStr
-try:
- import decimal
-except ImportError:
- decimal = None
+import decimal
@@ -79,7 +76,7 @@
return self.formatDateTime(val)
elif isinstance(val, (int, long, float)):
return str(val)
- elif decimal is not None and isinstance(val, decimal.Decimal):
+ elif isinstance(val, decimal.Decimal):
return str(val)
elif isinstance(val, dNoEscQuoteStr):
return val
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/db/dCursorMixin.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -8,13 +8,7 @@
import sys
import re
import array
-# Make sure that the user's installation supports Decimal.
-_USE_DECIMAL = True
-try:
- from decimal import Decimal
-except ImportError:
- _USE_DECIMAL = False
-
+from decimal import Decimal
import dabo
import dabo.dConstants as kons
from dabo.dLocalize import _
@@ -233,7 +227,7 @@
ret = field_val
else:
return ret
- elif _USE_DECIMAL and pythonType in (Decimal,):
+ elif pythonType in (Decimal,):
ds = self.DataStructure
ret = None
_field_val = field_val
@@ -1509,7 +1503,7 @@
typ = dabo.db.getPythonType(field_type)
# Handle the non-standard cases
- if _USE_DECIMAL and typ is Decimal:
+ if typ is Decimal:
newval = Decimal()
# If the backend reports a decimal scale, use
it. Scale refers to the
# number of decimal places.
Modified: trunk/dabo/db/dDataSet.py
===================================================================
--- trunk/dabo/db/dDataSet.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/db/dDataSet.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -5,13 +5,8 @@
from dabo.dLocalize import _
import datetime
-# Make sure that the user's installation supports Decimal.
-_USE_DECIMAL = True
+from decimal import Decimal
try:
- from decimal import Decimal
-except ImportError:
- _USE_DECIMAL = False
-try:
from pysqlite2 import dbapi2 as sqlite
except ImportError:
try:
@@ -50,22 +45,18 @@
# We may need to encode fields that are not legal names.
self.fieldAliases = {}
- if _USE_DECIMAL:
- sqlite.register_adapter(Decimal, self._adapt_decimal)
+ sqlite.register_adapter(Decimal, self._adapt_decimal)
# When filtering datasets, we need a reference to the dataset
# this dataset was derived from.
self._sourceDataSet = None
self._encoding = "utf8"
# Register the converters
- if _USE_DECIMAL:
- sqlite.register_converter("decimal",
self._convert_decimal)
+ sqlite.register_converter("decimal", self._convert_decimal)
self._typeDict = {int: "integer", long: "integer", str: "text",
unicode: "text", float: "real", datetime.date:
"date",
- datetime.datetime: "timestamp"}
- if _USE_DECIMAL:
- self._typeDict[Decimal] = "decimal"
+ datetime.datetime: "timestamp", Decimal:
"decimal"}
def __del__(self):
@@ -81,15 +72,10 @@
def _convert_decimal(self, strval):
- """This is a converter routine. Takes the string
- representation of a Decimal value and return an actual
- decimal, if that module is present. If not, returns a float.
+ """This is a converter routine. Takes the string representation
of a
+ Decimal value and return an actual decimal.
"""
- if _USE_DECIMAL:
- ret = Decimal(strval)
- else:
- ret = float(strval)
- return ret
+ return Decimal(strval)
def _index(self, rec):
Modified: trunk/dabo/db/dbMySQL.py
===================================================================
--- trunk/dabo/db/dbMySQL.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/db/dbMySQL.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
import datetime
-try:
- import decimal
-except ImportError:
- decimal = None
+import decimal
import dabo
from dabo.dLocalize import _
from dBackend import dBackend
@@ -29,20 +26,19 @@
port = 3306
kwargs = {}
- if decimal is not None:
- # MySQLdb doesn't provide decimal converter by default,
so we do it here
- from MySQLdb import converters
- from MySQLdb import constants
+ # MySQLdb doesn't provide decimal converter by default, so we
do it here
+ from MySQLdb import converters
+ from MySQLdb import constants
- DECIMAL = constants.FIELD_TYPE.DECIMAL
- conversions = converters.conversions.copy()
- conversions[DECIMAL] = decimal.Decimal
+ DECIMAL = constants.FIELD_TYPE.DECIMAL
+ conversions = converters.conversions.copy()
+ conversions[DECIMAL] = decimal.Decimal
- def dec2str(dec, dic):
- return str(dec)
+ def dec2str(dec, dic):
+ return str(dec)
- conversions[decimal.Decimal] = dec2str
- kwargs["conv"] = conversions
+ conversions[decimal.Decimal] = dec2str
+ kwargs["conv"] = conversions
try:
self._connection = dbapi.connect(host=connectInfo.Host,
Modified: trunk/dabo/lib/reportUtils.py
===================================================================
--- trunk/dabo/lib/reportUtils.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/lib/reportUtils.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -1,12 +1,7 @@
# -*- coding: utf-8 -*-
import datetime
-_USE_DECIMAL = True
-try:
- from decimal import Decimal
-except ImportError:
- _USE_DECIMAL = False
-
+from decimal import Decimal
import os
import sys
import tempfile
@@ -84,11 +79,9 @@
unicode: "str",
bool: "bool",
datetime.date: "datetime.date",
- datetime.datetime: "datetime.datetime",}
+ datetime.datetime: "datetime.datetime",
+ Decimal: "Decimal"}
- if _USE_DECIMAL:
- typemap[Decimal] = "Decimal"
-
xml = """\t<testcursor """
for k, v in dataset[0].items():
xml += """%s="%s" """ % (k, typemap.get(type(v)))
Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/lib/reportWriter.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -2,12 +2,8 @@
import copy
import datetime
-_USE_DECIMAL = True
-try:
- import decimal
- Decimal = decimal.Decimal
-except ImportError:
- _USE_DECIMAL = False
+import decimal
+Decimal = decimal.Decimal
import locale
import sys
Modified: trunk/dabo/ui/uiwx/dControlItemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dControlItemMixin.py 2008-08-27 16:28:05 UTC (rev
4460)
+++ trunk/dabo/ui/uiwx/dControlItemMixin.py 2008-08-27 16:32:20 UTC (rev
4461)
@@ -101,13 +101,18 @@
sortFunction = self._sortFunction
self._choices.sort(sortFunction)
+
def _resetChoices(self):
+ """Sequence required to update the choices for the list.
Refactored out
+ to avoid duplicate code.
+ """
self.Clear()
self._setSelection(-1)
if self._sorted:
self.sort()
self.AppendItems(self._choices)
-
+
+
# Property get/set/del methods follow. Scroll to bottom to see the
property
# definitions themselves.
def _getChoices(self):
Modified: trunk/dabo/ui/uiwx/dFont.py
===================================================================
--- trunk/dabo/ui/uiwx/dFont.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/ui/uiwx/dFont.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import wx
-import decimal
import dabo
from dabo.dObject import dObject
from dabo.dLocalize import _
Modified: trunk/dabo/ui/uiwx/dSearchBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dSearchBox.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/ui/uiwx/dSearchBox.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -188,17 +188,11 @@
# skip it: mx may not be available
pass
- try:
- import decimal
- class DecimalText(TestBase):
- def afterInit(self):
- self.Value = decimal.Decimal("23.42")
+ import decimal
+ class DecimalText(TestBase):
+ def afterInit(self):
+ self.Value = decimal.Decimal("23.42")
+ testParms.append(DecimalText)
- testParms.append(DecimalText)
-
- except ImportError:
- # decimal only in python >= 2.4
- pass
-
test.Test().runTest(testParms)
Modified: trunk/dabo/ui/uiwx/dSlidePanelControl.py
===================================================================
--- trunk/dabo/ui/uiwx/dSlidePanelControl.py 2008-08-27 16:28:05 UTC (rev
4460)
+++ trunk/dabo/ui/uiwx/dSlidePanelControl.py 2008-08-27 16:32:20 UTC (rev
4461)
@@ -60,6 +60,7 @@
self.Collapsed = collapsed
# Enable detection of clicks on the caption bar
self._captionBar.Bind(wx.EVT_LEFT_UP, self.__onWxCaptionClick)
+ print "CAP BAR BINDING"
# Set up the sizer
self._baseSizer = sz = dabo.ui.dSizer("v")
self.SetSizer(sz, True)
@@ -85,8 +86,24 @@
if ret.GetHeight() > pHt - capHt:
ret.SetHeight(pHt - capHt)
return ret
-
-
+
+
+ def ResizePanel(self):
+ """The native FoldPanelBar doesn't handle removing items form
panels;
+ this removes the item from the panel's internal item tracking.
+ """
+ for itm in self._items:
+ if not itm._wnd:
+ self._items.remove(itm)
+ super(dSlidePanel, self).ResizePanel()
+
+
+ def Destroy(self):
+ self.Parent._panels.remove(self)
+ self.Parent.raiseEvent(dEvents.SlidePanelChange)
+ super(dSlidePanel, self).Destroy()
+
+
def onChildBorn(self, evt):
self._cont.lockDisplay()
ch = evt.child
@@ -116,6 +133,7 @@
def __onWxCaptionClick(self, evt):
+ print "WX CAP CLICK"
self.raiseEvent(dEvents.SlidePanelCaptionClick, evt)
@@ -237,13 +255,20 @@
def _getPanelPosition(self):
- return self._cont.Children.index(self)
+ try:
+ ret = self._cont.Children.index(self)
+ except (ValueError, IndexError):
+ ret = None
+ return ret
def _setPanelPosition(self, val):
if self._constructed():
if val == self.PanelPosition:
return
cnt = self._cont
+ if self not in cnt._panels:
+ # Not fully constructed yet
+ return
cnt._panels.remove(self)
cnt._panels.insert(val, self)
cnt.raiseEvent(dEvents.SlidePanelChange)
@@ -382,11 +407,13 @@
self.raiseEvent(dEvents.SlidePanelChange,
self._createCapBarEvt(pnl))
pnl.bindEvent(dEvents.SlidePanelCaptionClick,
- self.onSlidePanelCaptionClick, pnl)
+ self.__onSlidePanelCaptionClick, pnl)
+ print "PANEL CAP CLICK BOUND"
return pnl
- def onSlidePanelCaptionClick(self, evt):
+ def __onSlidePanelCaptionClick(self, evt):
+ print "DABO CAPCLK", self.SingleClick
if self.SingleClick:
obj = evt.EventObject
obj.Expanded = not obj.Expanded
@@ -623,7 +650,8 @@
if not pnl.Caption:
pnl.Caption = _("Panel %s") %
(i+1,)
elif val < panelCount:
- raise ValueError, _("Cannot reduce PanelCount.")
+ for i in range(panelCount, val, -1):
+ self.Panels[i-1].release()
else:
self._properties["PanelCount"] = val
Modified: trunk/dabo/ui/uiwx/dTextBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dTextBox.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/ui/uiwx/dTextBox.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -85,17 +85,12 @@
# skip it: mx may not be available
pass
- try:
- import decimal
- class DecimalText(TestBase):
- def afterInit(self):
- self.Value = decimal.Decimal("23.42")
+ import decimal
+ class DecimalText(TestBase):
+ def afterInit(self):
+ self.Value = decimal.Decimal("23.42")
- testParms.append(DecimalText)
+ testParms.append(DecimalText)
- except ImportError:
- # decimal only in python >= 2.4
- pass
-
test.Test().runTest(testParms)
Modified: trunk/dabo/ui/uiwx/dTextBoxMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dTextBoxMixin.py 2008-08-27 16:28:05 UTC (rev 4460)
+++ trunk/dabo/ui/uiwx/dTextBoxMixin.py 2008-08-27 16:32:20 UTC (rev 4461)
@@ -7,15 +7,9 @@
import wx.lib.masked as masked
import dabo.lib.dates
-try:
- import decimal
- numericTypes = (int, long, decimal.Decimal, float)
- valueErrors = (ValueError, decimal.InvalidOperation)
-except ImportError:
- # decimal is only in Python 2.4 or greater
- decimal = None
- numericTypes = (int, long, float)
- valueErrors = (ValueError, )
+import decimal
+numericTypes = (int, long, decimal.Decimal, float)
+valueErrors = (ValueError, decimal.InvalidOperation)
# Make this locale-independent
decimalPoint = locale.localeconv()["decimal_point"]
@@ -453,7 +447,7 @@
retVal = mx.DateTime.TimeFrom(str(strVal))
except ImportError:
raise ValueError, _("Can't import mx.DateTime")
- elif decimal is not None and (dataType == decimal.Decimal) and
self.StrictNumericEntry:
+ elif (dataType == decimal.Decimal) and self.StrictNumericEntry:
try:
_oldVal = self._oldVal
except AttributeError:
@@ -478,10 +472,7 @@
else:
retVal = int(strVal)
else:
- if decimal.Decimal in numericTypes:
- retVal = decimal.Decimal(strVal)
- else:
- retVal = float(strVal)
+ retVal = decimal.Decimal(strVal)
except valueErrors:
raise ValueError, _("Invalid Numeric Value:
%s") % strVal
else:
_______________________________________________
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]