>> I have "RESTRICT" at DB level. >> Whenever I wish to delete a parent record, I am in a fix (irrespective >> of REFINTEG=3 or 2 in dabo). >> Because at DB level, it will not allow to delete a parent row when child >> rows are there referencing this parent row). >> >> That's why I need to delete the child rows in order from bottom to top >> in beforeDelete(). >> Then delete the parent. > Ok, now I understand. Any security rationale for doing that? > It's very unhandy. > In this situation you should use framework REFINTEG_RESTRICT integrity rule, > then write deleteUpward() method yourself, e.g.: > > <code> > def deleteUpward(self, startTransaction=True): > > startTransaction = startTransaction and self.beginTransaction() > try: > self.deleteAll(startTransaction=False) > parent = self.Parent > if parent: > parent.deleteUpward(startTransaction=False) > if startTransaction: > self.commitTransaction() > except (dException.DBQueryException, StandardError): > if startTransaction: > self.rollbackTransaction() > raise > </code> > > Conditionally, you can use beforeDelete method, but remember that there will > be no single transaction, but one per business object. Can we construct a logic (maybe a recursive def) by which the parent-child chain down the line can be listed. Then construct "deleteUpward()" method, which when called, will delete child records from childs tables, one-by-one, from bottom table to top.
> Any security rationale for doing that? Yes. There are reasons like--- * When I want to delete a child only, and not its parent, I can't give CASCADE in MySQL. * Although the DB will be at a secured machine, somebody might try to delete a parent directly from MySQL query browser (knowingly or inadvertently). Regards, Vineet _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[email protected]
