From f049e2fff46a30263d9d360364603ea56580dc1d Mon Sep 17 00:00:00 2001 From: helmutm Date: Wed, 20 Jan 2010 14:40:32 +0000 Subject: [PATCH] make search (i.e. vocabulary) for relation set fields/widgets configurable git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3691 fd906abe-77d9-0310-91a1-e0d9ade77398 --- schema/base.py | 3 +++ schema/field.py | 3 ++- search/browser.py | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/schema/base.py b/schema/base.py index 4de7b6b..adb6079 100644 --- a/schema/base.py +++ b/schema/base.py @@ -48,6 +48,8 @@ class IRelationSet(IList): target_types = Attribute('A list of names that denote types of ' 'loops objects (typically concept types) that may be used as ' 'targets for the relations.') + selection_view = Attribute('The name of a view that provides a collection ' + 'of candidates to select from, in JSON format.') class Relation(Field): @@ -75,5 +77,6 @@ class RelationSet(List): def __init__(self, *args, **kw): self.target_types = kw.pop('target_types') + self.selection_view = kw.pop('selection_view', None) super(RelationSet, self).__init__(*args, **kw) diff --git a/schema/field.py b/schema/field.py index c9e2fa1..76ff78f 100644 --- a/schema/field.py +++ b/schema/field.py @@ -47,7 +47,8 @@ class BaseRelationFieldInstance(object): @Lazy def selection_view(self): - return getattr(self.context, 'selection_view', 'listConceptsForComboBox.js') + return (getattr(self.context, 'selection_view', None) or + 'listConceptsForComboBox.js') @Lazy def typesParams(self): diff --git a/search/browser.py b/search/browser.py index 06867fd..df25d54 100644 --- a/search/browser.py +++ b/search/browser.py @@ -89,7 +89,7 @@ class Search(BaseView): 'dojo.require("dojox.data.QueryReadStore");') cm.register('js-execute', jsCall, jsCall=jsCall) - def listConcepts(self): + def listConcepts(self, filterMethod=None): """ Used for dijit.FilteringSelect. """ request = self.request @@ -113,6 +113,8 @@ class Search(BaseView): for o in result: if o.getLoopsRoot() == self.loopsRoot: adObj = adapted(o, self.languageInfo) + if filterMethod is not None and not filterMethod(adObj): + continue name = self.getRowName(adObj) if title and title.endswith('*'): title = title[:-1]