Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6823499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:47:23+00:00 2026-05-26T21:47:23+00:00

I have two Dexterity content types – Participant & Criterion – the latter of

  • 0

I have two Dexterity content types – Participant & Criterion – the latter of which is used to determine participant inclusion in a project. Criteria are stored on the Participant as a RelationList, however I’d like to replace the default picker widget with a checkbox based one. I’ve created a custom widget that I’m assigning to the criteria field which displays the correct criteria as checkboxes, but gives me the following error when it validates:

2011-11-04 00:27:26 ERROR Zope.SiteErrorLog 1320380846.610.720672558798 http://192.168.2.128:8080/ctcc/Trials/trial1/sites/site1/++add++ctcc.Participant
Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module plone.z3cform.layout, line 70, in __call__
  Module plone.z3cform.layout, line 54, in update
  Module plone.z3cform.fieldsets.extensible, line 59, in update
  Module plone.z3cform.patch, line 30, in GroupForm_update
  Module z3c.form.group, line 125, in update
  Module z3c.form.form, line 134, in updateWidgets
  Module z3c.form.field, line 275, in update
  Module z3c.form.browser.checkbox, line 44, in update
  Module z3c.form.browser.widget, line 70, in update
  Module z3c.form.widget, line 200, in update
  Module z3c.form.widget, line 84, in update
  Module z3c.form.widget, line 216, in extract
AttributeError: 'list' object has no attribute 'getTermByToken'

I have defined the widget like so:

class ICriteriaListingWidget(Interface):
    """Marker interface for the criteria listing widget"""

class CriteriaSelectionWidget(CheckBoxWidget):
    implements(ICriteriaListingWidget)
    klass = u'criteria-listing-widget'
    input_template = ViewPageTemplateFile('criteria_listing_input.pt')
    display_template = ViewPageTemplateFile('criteria_listing_display.pt')

    @property
    def terms(self):
        catalog = getToolByName(self.context, 'portal_catalog')
        content = catalog(
            portal_type='ctcc.Criterion',
        )
        return [SimpleTerm(x.id, x, title=x.Title) for x in content]

@adapter(IRelationList, IFormLayer)
@implementer(IFieldWidget)
def CriteriaListingWidget(field, request):
    return FieldWidget(field, CriteriaSelectionWidget(request))

Then on the Participant Dexterity type, the field is:

form.widget(criteria=CriteriaListingWidget)
criteria = RelationList(
    title = _(u'Inclusion Criteria'),
    description = _(u'The participant criteria evaluated against for inclusion'),
    value_type = RelationChoice(
        source = ObjPathSourceBinder(
            object_provides = ICriterion.__identifier__,
        ),
    ),
    default = [],
    required = False,
)

Given the nature of the error, I replaced the ObjPathSourceBinder source with a custom Vocabulary for criteria hoping it would return objects with the correct interface, but I’m seeing the exact same errors using that solution.

UPDATE: I’ve wrapped the terms list in a SimpleVocabulary as suggested but it just shifts the problem along. Note that the error is now occurring in kss_z3cform_inline_validation.

2011-11-06 19:24:36 ERROR Zope.SiteErrorLog 1320625476.430.209960132592 http://192.168.2.128:8080/ctcc/Trials/trial1/sites/site1/kss_z3cform_inline_validation
Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module <wrapper>, line 5, in wrapper
  Module kss.core.actionwrapper, line 236, in apply
  Module plone.app.z3cform.kss.validation, line 51, in validate_input
  Module z3c.form.group, line 92, in extractData
  Module z3c.form.form, line 145, in extractData
  Module z3c.form.field, line 301, in extract
  Module z3c.form.converter, line 311, in toFieldValue
AttributeError: 'SimpleVocabulary' object has no attribute 'getValue'
2011-11-06 19:24:36 ERROR plone.transformchain Unexpected error whilst trying to apply transform chain
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:47:23+00:00Added an answer on May 26, 2026 at 9:47 pm

    I’m not sure if this counts as an answer per se but I ended up avoiding the need for a custom widget by creating custom Source & SourceBinder objects.

    class CTCCSource(object):
        implements(IVocabularyTokenized)
    
        container    = None
        content_type = None
    
        def __init__(self, context):
            self.context = context
            container_path = self._container_path(context)
            self.catalog = getToolByName(context, 'portal_catalog')
            self.intid_utility = getUtility(IIntIds)
            self.content = [i.getObject() for i in self.catalog(portal_type=self.content_type, path={'query': container_path})]
    
        def _container_path(self, context):
            physical_path = list(context.getPhysicalPath())
            trial_path = physical_path[:physical_path.index('sites')]
            criteria_path = trial_path + [self.container]
            return '/'.join(criteria_path)
    
        def __contains__(self, term):
            return term in self.content
    
        def __iter__(self):
            for crit in self.content:
                yield SimpleTerm(crit, self.intid_utility.getId(crit), crit.Title)
    
        def __len__(self):
            return len(self.content)
    
        def getTerm(self, obj):
            return SimpleVocabulary.createTerm(
                obj, self.intid_utility.getId(obj), obj.Title()
            )
    
        def getTermByToken(self, value):
            return self.getTerm(self.intid_utility.getObject(int(value)))
    
    class CTCCSourceBinder(object):
        implements(IContextSourceBinder)
        source = None
    
        def __init__(self, **kw):
            pass
    
        def __call__(self, context):
            return self.source(context)
    

    This allowed me to produce form checkbox fields from content contained within the current context, adding references to the chosen options into a RelatedList.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two arrays consisting of a list emails which I need to send
Have two IBOutlets which won't appear in File's Owner to connect to even though
I have a custom folderish Dexterity content-type in Plone. It can have only Documents
I have two tables which have a column in common, how can I retrieve
I have two sets of vertexes used as a line strip: Vertexes1 Vertexes2 It's
I have two view controllers named view1ViewController and view2ViewController in an cocoa touch project,
I have two classes, which reference the third: class Data1 { public Named Xxx
Have two folders with approx. 150 java property files. In a shell script, how
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.