#NEWLINE# @ classmethod #NEWLINE# def delete_super( cls , table , record ) : #NEWLINE# #INDENT# '\n            Removes the super-entity links of an instance record\n\n            @param table: the instance table\n            @param record: the instance record\n\n            @return: True if successful, otherwise False (caller must\n                     roll back the transaction if False is returned!)\n        ' #NEWLINE# record_id = record . get ( table . _id . name , None ) #NEWLINE# if ( not record_id ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Record ID required for delete_super' ) #NEWLINE# #UNINDENT# get_config = cls . get_config #NEWLINE# supertables = get_config ( table . _tablename , 'super_entity' ) #NEWLINE# if ( not supertables ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# if ( not isinstance ( supertables , ( list , tuple ) ) ) : #NEWLINE# #INDENT# supertables = [ supertables ] #NEWLINE# #UNINDENT# keys = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# load = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for sname in supertables : #NEWLINE# #INDENT# stable = ( cls . table ( sname ) if isinstance ( sname , str ) else sname ) #NEWLINE# if ( stable is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# key = stable . _id . name #NEWLINE# if ( key in record ) : #NEWLINE# #INDENT# keys [ stable . _tablename ] = ( key , record [ key ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# load [ stable . _tablename ] = key #NEWLINE# #UNINDENT# #UNINDENT# if load : #NEWLINE# #INDENT# row = current . db ( ( table . _id == record_id ) ) . select ( table . _id , * load . values ( ) , limitby = ( 0 , 1 ) ) . first ( ) #NEWLINE# for ( sname , key ) in load . items ( ) : #NEWLINE# #INDENT# keys [ sname ] = ( key , row [ key ] ) #NEWLINE# #UNINDENT# #UNINDENT# define_resource = current . s3db . resource #NEWLINE# update_record = record . update_record #NEWLINE# for sname in keys : #NEWLINE# #INDENT# ( key , value ) = keys [ sname ] #NEWLINE# if ( not value ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# update_record ( ** { #NEWLINE# #INDENT# key : None , #NEWLINE# #UNINDENT# } ) #NEWLINE# sresource = define_resource ( record , id = value ) #NEWLINE# sresource . delete ( cascade = True ) #NEWLINE# if sresource . error : #NEWLINE# #INDENT# update_record ( ** { #NEWLINE# #INDENT# key : value , #NEWLINE# #UNINDENT# } ) #NEWLINE# return False #NEWLINE# #UNINDENT# #UNINDENT# return True