Zope3 checkObject vs z3ext checkObject

Replies: 0
Up one level
Pages: [1]
Zope3 checkObject vs z3ext checkObject
« on: October 23, 2009 18:11:30 +0000 »
Hi guys,

      We are trying to specify a customized precondition, which should validate a contenttype before it is added.
      According to the Zope3 documentation, we should proceed as presented below (copy/paste from zope.app.container.constraints.py from zope.app.container-3.5.6-py2.5-linux-i686.egg):

   >>> def preNoZ(container, name, ob):
   ...     "Silly precondition example"
   ...     if name.startswith("Z"):
   ...         raise zope.interface.Invalid("Names can not start with Z")

   >>> class I1(zope.interface.Interface):
   ...     def __setitem__(name, on):
   ...         "Add an item"
   ...     __setitem__.precondition = preNoZ

   >>> from zope.app.container.interfaces import IContainer
   >>> class C1(object):
   ...     zope.interface.implements(I1, IContainer)
   ...     def __repr__(self):
   ...         return 'C1'

However z3ext seems to overwrite checkObject, implementing its own method, which is located in: z3ext.content.type.constraints.py inside z3ext.content.type.-1.1.0-py2.5.egg.

My question is: Is there a way to add my own validation (for instance, as presented in Zope3 piece of code, above) as precondition, to the z3ext validation?

                          Thanks and regards
Carlos Moreira

Actions

Notifications