diff roundup/backends/back_anydbm.py @ 5067:e424987d294a

Add support for an integer type to join the existing number type. Commit patch supplied for issue2550886. This can be used for properties used for ordering, counts etc. where a decimal point isn't needed. Developed by Anthony (antmail). Doc updates written by John Rouillard.
author John Rouillard <rouilj@ieee.org>
date Sun, 05 Jun 2016 00:17:26 -0400
parents 5251e97b1de0
children e74c3611b138
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py	Tue May 31 09:16:09 2016 +0200
+++ b/roundup/backends/back_anydbm.py	Sun Jun 05 00:17:26 2016 -0400
@@ -1001,6 +1001,12 @@
                 except ValueError:
                     raise TypeError('new property "%s" not numeric'%key)
 
+            elif value is not None and isinstance(prop, hyperdb.Integer):
+                try:
+                    int(value)
+                except ValueError:
+                    raise TypeError('new property "%s" not an integer'%key)
+
             elif value is not None and isinstance(prop, hyperdb.Boolean):
                 try:
                     int(value)
@@ -1342,6 +1348,13 @@
                     raise TypeError('new property "%s" not '
                         'numeric'%propname)
 
+            elif value is not None and isinstance(prop, hyperdb.Integer):
+                try:
+                    int(value)
+                except ValueError:
+                    raise TypeError('new property "%s" not '
+                        'numeric'%propname)
+
             elif value is not None and isinstance(prop, hyperdb.Boolean):
                 try:
                     int(value)
@@ -1748,6 +1761,14 @@
                         v = [v]
                 l.append((OTHER, k, [float(val) for val in v]))
 
+            elif isinstance(propclass, hyperdb.Integer):
+                if type(v) != type([]):
+                    try :
+                        v = v.split(',')
+                    except AttributeError :
+                        v = [v]
+                l.append((OTHER, k, [int(val) for val in v]))
+
         filterspec = l
 
         # now, find all the nodes that are active and pass filtering

Roundup Issue Tracker: http://roundup-tracker.org/