[Zope-dev] z3c.form - ComputedErrorViewMessage

Martin Aspeli optilude+lists at gmail.com
Tue Mar 9 05:33:52 EST 2010


Hi,

I'm struggling to get custom ComputedErrorViewMessage adapters to work 
in z3c.form. I'm still debugging, but I came across this:

In error.py:

   ErrorViewMessage = value.StaticValueCreator(
     discriminators = ('error', 'request', 'widget', 'field', 'form', 
'content')
     )

ComputedErrorViewMessage = value.ComputedValueCreator(
     discriminators = ('error', 'request', 'widget', 'field', 'form', 
'content')
     )


class ErrorViewSnippet(object):

     ...

     def update(self):
         value = zope.component.queryMultiAdapter(
             (self.context, self.request, self.widget,
              self.field, self.form, self),
             interfaces.IValue, name='message')
         if value is not None:
             self.message = value.get()
         else:
             self.message = self.createMessage()

     ...

 From what I can tell, self.context is the exception; self.request, 
self.widget, self.field and self.form are as you'd expect. But the last 
discriminator, 'content' does not match up with 'self' (i.e. the error 
view snippet).

So, which is right? The discriminator on the value adapter factory, or 
the multi-adapter lookup? The documentation mentions 'content' as the 
discriminator, but doesn't define it any further.

FWIW, my expection is that 'content' should be the form's context 
content object.

Martin



More information about the Zope-Dev mailing list