[z3-five] using getToolByName in utility

Dennis Schulz d.schulz81 at gmx.net
Wed Jan 31 11:19:15 CET 2007


Hello...

I made an utility (vocabulary factory) that returns all users. It 
queries the membership tool. (see code at the end)
That works fine for displaying it as a dropdown in a formlib form.
However, when change a value and submit the form, the utility gets 
called in a weird context by the formlib validation machinery.
When I print out aq_chain then I only have one object without base request.
Within this weird context the getToolByName loopup is not possible.

Is there any workaround except trying to skip validation (how?)?

Dennis

class UserVocabulary(object):
    implements(IVocabularyFactory)
    def __call__(self, context):
            context = getattr(context, 'context', context)
            context = aq_inner(context)
            print aq_chain(context)
            mt = getToolByName(context, 'portal_membership')
            memberids = mt.listMemberIds()
            result=[( mt.getMemberById(i).getProperty('fullname'),i) for 
i in memberids]
            return SimpleVocabulary.fromItems(result)
UserVocabularyFactory = UserVocabulary()








More information about the z3-five mailing list