Issue 1694893
Created on 2007-04-05 10:40 by bruynooghef, last changed 2007-08-29 16:41 by jpend.
msg3474 |
Author: [hidden] (bruynooghef) |
Date: 2007-04-05 10:40 |
|
Hi
It would be nice if it was possible to assign sets to multilink properties as well as lists. e.g.:
>>> ppl = set(db.issue.get(nodeid, 'nosy'))
>>> ppl.add(db.user.lookup('someone'))
>>> db.issue.set(nodeid, nosy=ppl)
instead of:
>>> db.issue.set(nodeid, nosy=list(ppl))
It may even make sense to return sets with the get() call?
Cheers
Floris
|
msg3475 |
Author: [hidden] (jpend) |
Date: 2007-08-29 03:33 |
|
Right now the backends check during set_inner whether type(incoming_value) == type([]) for Multilinks. Really any finite interator would work; it looks like all roundup does is "for x in incoming_value". We could replace the type check with "hasattr(x, '__iter__') and let any iterator through. Then we wouldn't have to enumerate all the things that are allowed (set, frozenset, list, tuple, etc).
I don't know the hyperdb well enough yet to know if there is a good reason to limit it to just lists. Maybe Richard can comment. If he's okay with it, I'll change backend_anydbm.py, backend_metakit.py, rdbms_common.py.
As for returning sets, did you have any specific use cases where returning a set would be a big win over getting a list back?
|
msg3476 |
Author: [hidden] (richard) |
Date: 2007-08-29 03:41 |
|
I don't have a problem with set() taking any iterable.
No, get() should not return sets - Multilinks are ordered sequences.
|
msg3477 |
Author: [hidden] (jpend) |
Date: 2007-08-29 16:41 |
|
Fix checked in CVS; multilinks can take any iterable. A unit test was added as well.
|
msg3478 |
Author: [hidden] (bruynooghef) |
Date: 2007-08-29 16:51 |
|
I agree that they shouldn't return sets with get(), not sure why I added that comment...
Making set() accept any iterable is cool, thanks!
|
|
Date |
User |
Action |
Args |
2007-04-05 10:40:08 | bruynooghef | create | |
|