Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Version 15 (modified by Chris Arndt, 11 years ago) (diff)



The information on this page is obsolete, incomplete or incorrect and left here only for reference and has not been ported to the new documentation wiki.

Please refer to the TurboGears documentation wiki for up-to-date documentation.

The docs clearly show how to insert/update a record, but not how to delete one.

If you have a reference to the object, simply call object.destroySelf() to remove it from the data base, provided it is not a foreign key or has any relationships depending on it.

If you do not have a reference to the object, simply use the delete class method:

class SampleSQLObject(SQLObject):
    # ...

If there are dependencies, you will have to delete the dependent records first (if at all.)

If there is a better way to do this, please update.

The way to cascade deletes is like this:

class Student(SQLObject):
    grade = sqlobject.ForeignKey('Grade', cascade=True)
class Grade(SQLObject):



It is better to use the "destroySelf" method instead of the delete method. So, you end up with:

student = Student.get(someid)

- Jorge Godoy