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

Changes between Initial Version and Version 1 of SimpleDelete


Ignore:
Timestamp:
11/13/05 20:31:56 (14 years ago)
Author:
luke@…
Comment:

Trivial, but not obvious.

Legend:

Unmodified
Added
Removed
Modified
  • SimpleDelete

    v1 v1  
     1The docs clearly show how to insert/update a record, but not how to delete one. 
     2 
     3If you have a reference to the object, simple call object.destroySelf() to remove it from the data base, '''provided it is not a foreign key or has any relationships depending on it.''' 
     4 
     5If you do not have a reference to the object, simply select to get the record, and dereference it to get the object reference. 
     6 
     7{{{ 
     8def remove(self, recordID): 
     9        myRecord = MyObject.selectBy(id=recordID) 
     10        if myRecord.count(): 
     11                myRecord = list(myRecord)[0] 
     12                myRecord.destroySelf() 
     13        else: 
     14                #Could not find record with that id. 
     15}}} 
     16 
     17If there are dependencies, you will have to delete the dependent records first (if at all.) 
     18 
     19If there is a better way to do this, please update.