[Zope-dev] constraints for ZCatalog.

Anthony Baxter anthony@interlink.com.au
Tue, 04 Jan 2000 17:29:50 +1100


Has anyone had any thoughts about adding constraints to ZCatalog?

I've got an application where the ability to say 'unique(colA, colB)'
would be very useful - it could be implemented simply enough in the
addObject code, check for the existence of an object matching the new
object's (colA,colB) values, and raise an exception if one is found.
   eg.
   if len(self._catalog.searchResults(colA=newobj.colA, colB=newobj.colB)):
	raise "Uniqueness constraint violated"

Another constraint would be to do something like 'colA refers_to colB'
and only allow an entry where there's a match for
   searchResults(colB=newobj.colA) 
or even an expanded syntax of something like
   colA, colB refers_to colC, colD
which would search for
   searchResults(colC=newobj.colA, colD=newobj.colB) 

This also requires putting checks in the update code, I guess, and the
delete code. blah.

Yes, these are all implementable in DTML or python at the time you add
it to the catalog, but it would be way cool if it was there automatically...

Anthony