vregistry.py
changeset 6389 72ba82a26e05
parent 6366 1806148d6ce8
child 6401 d7f5d873e1b8
--- a/vregistry.py	Mon Oct 04 18:55:57 2010 +0200
+++ b/vregistry.py	Mon Oct 04 18:56:05 2010 +0200
@@ -195,6 +195,18 @@
     select_object = deprecated('[3.6] use select_or_none instead of select_object'
                                )(select_or_none)
 
+    def selectable(self, oid, *args, **kwargs):
+        """return all appobjects having the given oid that are
+        selectable against the given context, in score order
+        """
+        objects = []
+        for appobject in self[oid]:
+            score = appobject.__select__(appobject, *args, **kwargs)
+            if score > 0:
+                objects.append((score, appobject))
+        return [obj(*args, **kwargs)
+                for _score, obj in sorted(objects)]
+
     def possible_objects(self, *args, **kwargs):
         """return an iterator on possible objects in this registry for the given
         context