disabling zope.schema constraint check in edit form

Joshua Immanuel <[email protected]>
Newsgroups gmane.comp.web.zope.bluebream,gmane.comp.web.zope.devel
Organization HiPro IT Solutions Private Limited
Message-ID <1313654396.2457.36.camel@jimman>
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,
                		constraint=check_for_uniqueness)
                ...
                
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
http://hipro.co.in
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEABECAAYFAk5MxncACgkQWw85XwuSFMLbxwCfW9+EiMccE39oekIpR60Cn4WU
2VsAnjy3a+U8ov6QIXdXN5DHIFXSJU1A
=2lxa
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.