Please note: this project is inactive since early 2006

4.4 Deleting an object

(We suppose here we already know how to get objects -this is covered by the next section)

When you want an object to be deleted, you inform it with the deleteObject message:

        >>> ec.deleteObject(aBook)

Alternatively, you can use the method delete ; both delete and deleteObject are completely equivalent, and depending on your own feeling you may prefer one or the other.

You can also discard the insertion of an object you've just added:

       >>> newBook = Book()
       >>> ec.insert(newBook)
       [... then at some point you can change your mind]
       >>> ec.delete(newBook)

Note that, before a deleted object is about to be made persistent (i.e. when its corresponding row in the database is about to be deleted), some logic is triggered. For example, if this object still has some relationships but these relationships are marked as CASCADE_DELETE, the objects in relations will be deleted as well (given that their own validation logic allows them to be deleted, of course). Or, if it is marked as DELETE_DENY, the deletion will be denied and for that object to be deleted, you will need to remove any object in relation with it.

You can refer to the next section, 4.6, and to relationships' properties described in section 2.6.2 for further details.

Comments are welcome: Sebastien Bigaret / Modeling Home Page
Hosted Logo