From f8afbe179e55442991369ce8b4eb8dd5c4680eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 17 Oct 2011 16:44:13 +0200 Subject: [PATCH] Hack around ObjPathSourceBinder to get the related docs type editable --- themis/fields/__init__.py | 6 +++--- themis/fields/vocabs.py | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/themis/fields/__init__.py b/themis/fields/__init__.py index 623160e..219b2dd 100644 --- a/themis/fields/__init__.py +++ b/themis/fields/__init__.py @@ -36,8 +36,8 @@ from themis.fields.interfaces import IDocHistoLine, IDocHistoLines from themis.fields.vocabs import SubjectsSource from themis.fields.vocabs import LegislativeSessionsSource +from themis.fields.vocabs import RelatedDocObjPathSourceBinder -from plone.formwidget.contenttree import ObjPathSourceBinder from z3c.relationfield.schema import Relation, RelationList @@ -349,14 +349,14 @@ class RelatedDoc(Relation): def __init__(self, **kw): super(RelatedDoc, self).__init__(**kw) - self.vocabulary = ObjPathSourceBinder() + self.vocabulary = RelatedDocObjPathSourceBinder() source = property(lambda self: self.vocabulary) def bind(self, object): """See zope.schema._bootstrapinterfaces.IField.""" clone = super(RelatedDoc, self).bind(object) - clone.vocabulary = self.vocabulary(object) + clone.vocabulary = RelatedDocObjPathSourceBinder()(object) return clone diff --git a/themis/fields/vocabs.py b/themis/fields/vocabs.py index 91e3a18..1cff646 100644 --- a/themis/fields/vocabs.py +++ b/themis/fields/vocabs.py @@ -13,6 +13,7 @@ from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from Products.CMFCore.utils import getToolByName from plone.registry.interfaces import IRegistry +from plone.formwidget.contenttree import ObjPathSourceBinder try: from tabellio.config.interfaces import ITabellioSettings @@ -266,3 +267,8 @@ class LegislativeSessionsSource(object): # Legislative sessions def __iter__(self): # hack to let schema editor handle the field yield u'DO NOT TOUCH' + +class RelatedDocObjPathSourceBinder(ObjPathSourceBinder): + def __iter__(self): + # hack to let schema editor handle the field + yield u'DO NOT TOUCH'