R: [Zope] Discussion: Best practice site struture (LONG)

Luca Olivetti luca@wetron.es
Thu, 11 Apr 2002 01:48:21 +0200


Max M wrote:


>> The management interface should show dangling links instead of just 
>> hiding them. 
> 
> 
> 
> Not in the current implementation. The product currently deletes 
> relations that no longer has valid objects. I did this so that you 
> cannot remove an object with one meta_type and add one with another 
> meta_type but the same id. This, I guess could seriously screw up the app.


Maybe I was doing something stupid (with all that banging my head on the 
wall trying to learn zope+cmf+zpt+writing python products all at once 
;-) but this is not what I saw: before I implemented manage_beforeDelete 
in my objects, I deleted one, I went to the management interface of the 
mxmRelation and saw that the relation wasn't there anymore -- good.
Then I created a new object with the same id and when I went to display 
it the old relation was still in place -- bad.

e.g.

proposal1 -> company1

deleted proposal1

created new proposal1 (which should be unrelated to company1) and saw 
that the old relation was still in place.

Since I didn't know of manage_beforeDelete at the time, in my object 
creation method I just put a call to delete dangling relations :-)

[...]
>> And if you want referential integrity you still have to code it by 
>> hand in each object (i.e. by implementing manage_beforeDelete).
> 
> 
> 
> This will probably never change. What should happen when an object is 
> deleted is application and object specific and cannot be more 
> generalized than to a hook.


Well, there are not so many cases and with postgres (not that I'm an 
expert of it, it just happens that I read a tutorial about foreign keys 
and referential integrity ;-) you can define what happens when you 
delete a record another table depends on:

1) do nothing
2) cascade delete (i.e.delete the record and all records depending on 
it, useful for example if you're trying to delete an invoice and its lines)
3) don't allow deleting the record

and that's it. But, as you say, that's not possible without 
modifications to zope core.

Bye

-- 
Luca Olivetti