dabo Commit
Revision 4489
Date: 2008-08-30 19:03:51 -0700 (Sat, 30 Aug 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4489

Changed:
U   trunk/dabo/dPref.py
U   trunk/dabo/ui/uiwx/dGrid.py
U   trunk/dabo/ui/uiwx/dShell.py

Log:
Added the deleteByValue() method to dPref. This enables you to delete all pref 
entries that contain the passed value.

Updated dShell so that if you re-use a command from its history, the old entry 
for the command is deleted. The effect is that the history only contains one 
instance of each command, with the most recent usage at the top.

Fixed a bare-exception removal bug in dGrid.buildFromDataSet() that didn't 
catch the case where the keyCaption dict was None.


Diff:
Modified: trunk/dabo/dPref.py
===================================================================
--- trunk/dabo/dPref.py 2008-08-29 18:32:14 UTC (rev 4488)
+++ trunk/dabo/dPref.py 2008-08-31 02:03:51 UTC (rev 4489)
@@ -305,6 +305,19 @@
                self._cursor.commitTransaction()
 
        
+       def deleteByValue(self, val):
+               """Removes any preferences at or below this object whose value
+               matches the passed value.
+               """
+               crs = self._cursor
+               sql = """delete from daboprefs 
+                               where ckey like ?
+                               and cvalue = ?"""
+               prm = ("%s%%" % self._getKey(), val)
+               crs.execute(sql, prm)
+               crs.commitTransaction()
+
+
        def flushCache(self):
                """Clear the cache, forcing fresh reads from the database."""
                for key, val in self._cache.items():

Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2008-08-29 18:32:14 UTC (rev 4488)
+++ trunk/dabo/ui/uiwx/dGrid.py 2008-08-31 02:03:51 UTC (rev 4489)
@@ -1898,7 +1898,12 @@
                try:
                        ret = self._Table.GetValue(row, col)
                except AttributeError:
-                       ret = super(dGrid, self).GetValue(row, col)
+                       try:
+                               ret = super(dGrid, self).GetValue(row, col)
+                       except AttributeError:
+                               # I have no idea why this would ever happen, 
but it does...
+                               # Returning None seems like a reasonable way to 
handle it.
+                               ret = None
                return ret
 
 
@@ -2150,7 +2155,7 @@
                        # Use the keyCaption values, if possible
                        try:
                                cap = keyCaption[colKey]
-                       except KeyError:
+                       except (KeyError, TypeError):
                                cap = colKey
                        col = self.addColumn(inBatch=True)
                        col.Caption = cap

Modified: trunk/dabo/ui/uiwx/dShell.py
===================================================================
--- trunk/dabo/ui/uiwx/dShell.py        2008-08-29 18:32:14 UTC (rev 4488)
+++ trunk/dabo/ui/uiwx/dShell.py        2008-08-31 02:03:51 UTC (rev 4489)
@@ -372,9 +372,12 @@
 
 
        def addToHistory(self, cmd):
+               chk = self.cmdHistKey
                if cmd == self._lastCmd:
                        # Don't add again
                        return
+               # Delete any old instances of this command
+               chk.deleteByValue(cmd)
                self._lastCmd = cmd
                stamp = "%s" % int(round(time.time() * 100, 0))
                self.cmdHistKey.setValue(stamp, cmd)




_______________________________________________
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]

Reply via email to