Hello all,

I use the zope.schema field's constraint parameter to check for the
uniqueness of a particular field like this

        class IMyObject(Interface):
                def check_for_uniqueness(value):
                        cat = getUtility(ICatalog)
                        results = cat.searchResults(object_name=value)
                        for rslt in results:
                                if rslt.name.lower() == value.lower():
                                        raise NameAlreadyExists(value)
                        return True
                name = TextLine(title=u'Name', required=True,
This goes well with the zope.formlib's AddForm. But in edit form if I
modify any other field other than the 'name' field I get the
'NameAlreadyExists' error. Worse case scenario is where I have a cancel
action button which just redirects to another page, that too screams for
the NameAlreadyExists error.

Is there a way to disable the constraint check in the EditForm if the
'name' field isn't modified?

What is the preferred way of doing these kind of checks?

Please guide me.

Joshua Immanuel
HiPro IT Solutions Private Limited

Attachment: signature.asc
Description: This is a digitally signed message part

Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to