Package s3 :: Module s3delete :: Class S3Delete
[frames] | no frames]

Class S3Delete

source code

object --+
         |
        S3Delete

Process to delete/archive records in a S3Resource

Instance Methods
 
__init__(self, resource, archive=None, representation=None)
Constructor
source code
 
__call__(self, cascade=False, replaced_by=None, skip_undeletable=False)
Main deletion process, deletes/archives all records in the resource
source code
 
extract(self)
Extract the rows to be deleted
source code
 
check_deletable(self, rows, check_all=False)
Check which rows in the set are deletable, collect all errors
source code
 
cascade(self, row, check_all=False)
Run the automatic deletion cascade: remove or update records referencing this row with ondelete!="RESTRICT"
source code
 
auto_delete_linked(self, row)
Auto-delete linked records if row was the last link
source code
 
archive_record(self, row, replaced_by=None)
Archive ("soft-delete") a record
source code
 
delete_record(self, row)
Delete a record
source code
 
super_keys(self)
List of super-keys (instance links) in this resource
source code
 
foreign_keys(self)
List of foreign key fields in this resource
source code
 
references(self)
A list of foreign keys referencing this resource, lazy property
source code
 
restrictions(self)
A list of foreign keys referencing this resource with ondelete="RESTRICT", lazy property
source code
 
introspect(self)
Introspect the resource to set process properties
source code
 
add_error(self, record_id, msg)
Add an error
source code
 
set_resource_error(self)
Set the resource.error
source code
 
log_errors(self)
Log all errors of this process instance
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, resource, archive=None, representation=None)
(Constructor)

source code 

Constructor

Parameters:
  • resource - the S3Resource to delete records from
  • archive - True|False to override global security.archive_not_delete setting
  • representation - the request format (for audit, optional)
Overrides: object.__init__

__call__(self, cascade=False, replaced_by=None, skip_undeletable=False)
(Call operator)

source code 

Main deletion process, deletes/archives all records in the resource

Parameters:
  • cascade - this is called as a cascade-action from another process (e.g. another delete)
  • skip_undeletable - delete whatever is possible, skip undeletable rows
  • replaced_by - dict of {replaced_id: replacement_id}, used by record merger to log which record has replaced which

extract(self)

source code 

Extract the rows to be deleted

Returns:
a Rows instance

check_deletable(self, rows, check_all=False)

source code 

Check which rows in the set are deletable, collect all errors

Parameters:
  • rows - the Rows to be deleted
  • check_all - find all restrictions for each record rather than from just one table (not standard because of performance cost)
Returns:
array of Rows found to be deletable NB those can still fail further down the cascade

cascade(self, row, check_all=False)

source code 

Run the automatic deletion cascade: remove or update records referencing this row with ondelete!="RESTRICT"

Parameters:
  • row - the Row to delete
  • check_all - process the entire cascade to reveal all errors (rather than breaking out of it after the first error)

auto_delete_linked(self, row)

source code 

Auto-delete linked records if row was the last link

Parameters:
  • row - the Row about to get deleted

archive_record(self, row, replaced_by=None)

source code 

Archive ("soft-delete") a record

Parameters:
  • row - the Row to delete
  • replaced_by - dict of {replaced_id: replacement_id}, used by record merger to log which record has replaced which
Returns:
True for success, False on error

delete_record(self, row)

source code 

Delete a record

Parameters:
  • row - the Row to delete
Returns:
True for success, False on error

super_keys(self)

source code 

List of super-keys (instance links) in this resource

Returns:
a list of field names
Decorators:
  • @property

foreign_keys(self)

source code 

List of foreign key fields in this resource

Returns:
a list of field names
Decorators:
  • @property

references(self)

source code 

A list of foreign keys referencing this resource, lazy property

Returns:
a list of Fields
Decorators:
  • @property

restrictions(self)

source code 

A list of foreign keys referencing this resource with ondelete="RESTRICT", lazy property

Returns:
a list of Fields
Decorators:
  • @property

introspect(self)

source code 

Introspect the resource to set process properties

add_error(self, record_id, msg)

source code 

Add an error

Parameters:
  • record_id - the record ID
  • msg - the error message

set_resource_error(self)

source code 

Set the resource.error

log_errors(self)

source code 

Log all errors of this process instance