You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a usecase where I need a relation field that only presents a narrowly subset of elements as possible related items to the user. The selection of possible elements is determined by the current element (the one that we are currently editing).
Please consider this stub version of a vocabulary:
from plone.app.vocabularies.catalog import CatalogVocabulary
from plone.memoize.instance import memoize
class SiblingVocabulary(CatalogVocabulary):
def __init__(self, context):
self.context = context
def __contains__(self, value):
print "contains"
return True # this is ok ;)
@property
@memoize
def brains(self):
# this overrides the property in CatalogVocabulary
print "brains", self.context
return [] # this is where I will compute the valid elements, using the context
it is used by this factory:
from zope.interface import implementer
from zope.schema.interfaces import IVocabularyFactory
@implementer(IVocabularyFactory)
class SiblingVocabularyFactory(object):
def __call__(self, context, query=None):
print "Factory", context
return SiblingVocabulary(context)
Note: the target of the getVocabulary request is my site-root (thus I do not get the expected context in my vocabulary factory) and not the expected-element.
Am I right to assume that this is a bug?
The text was updated successfully, but these errors were encountered:
Hi there,
I have a usecase where I need a relation field that only presents a narrowly subset of elements as possible related items to the user. The selection of possible elements is determined by the current element (the one that we are currently editing).
Please consider this stub version of a vocabulary:
it is used by this factory:
which is configured like this in the
config.zcml
The widget/field is configured like this:
Now. If I open the edit mode I get this printout:
Factory <Folder expected-element>
But when I click the widget in order to display all valid elements I get this:
This corresponds to these two requests I see in my browser:
Note: the target of the
getVocabulary
request is my site-root (thus I do not get the expected context in my vocabulary factory) and not theexpected-element
.Am I right to assume that this is a bug?
The text was updated successfully, but these errors were encountered: