Mercurial > p > roundup > code
diff roundup/backends/rdbms_common.py @ 3869:16faac822fe5
Allow Multilinks to take any iterable
Change create_inner & set_inner to allow any iterable for
Multilinks.
Added a test to make sure they work and that we raise an exception
for non-iterables.
| author | Justus Pendleton <jpend@users.sourceforge.net> |
|---|---|
| date | Wed, 29 Aug 2007 16:40:20 +0000 |
| parents | bb30bbfc7cdd |
| children | 34128a809e22 |
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py Tue Aug 28 22:37:45 2007 +0000 +++ b/roundup/backends/rdbms_common.py Wed Aug 29 16:40:20 2007 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: rdbms_common.py,v 1.186 2007-06-21 07:35:50 schlatterbeck Exp $ +#$Id: rdbms_common.py,v 1.187 2007-08-29 16:40:20 jpend Exp $ """ Relational database (SQL) backend common code. Basics: @@ -1363,8 +1363,8 @@ (self.classname, newid, key)) elif isinstance(prop, Multilink): - if type(value) != type([]): - raise TypeError, 'new property "%s" not a list of ids'%key + if not hasattr(value, '__iter__'): + raise TypeError, 'new property "%s" not an iterable of ids'%key # clean up and validate the list of links link_class = self.properties[key].classname @@ -1613,8 +1613,8 @@ (self.classname, nodeid, propname)) elif isinstance(prop, Multilink): - if type(value) != type([]): - raise TypeError, 'new property "%s" not a list of'\ + if not hasattr(value, '__iter__'): + raise TypeError, 'new property "%s" not an iterable of'\ ' ids'%propname link_class = self.properties[propname].classname l = []
