Documentation¶
This module contains metaclasses which limit the changing member variables of a class once it has been instantiated – that is, after the __init__
function.
The level of access restriction is governed by the attr_mod_ctrl
attribute of the class. The possible values for this variable are 'const'
, 'all'
, 'new'
or 'none'
.
attr_mod_ctrl == 'const'
prohibits any kind of change to the instance attributes, and also prohibits changing theattr_mod_ctrl
variable.attr_mod_ctrl == 'all'
prohibits any changes to the instance attributes, but theattr_mod_ctrl
itself can be changedattr_mod_ctrl == 'new'
prohibits the creation of new attributes and deletion of existing ones.attr_mod_ctrl == 'none'
does nothing.
Note
The functionality provided in this module should not be used for security purposes. It is intended only for avoiding accidental changes in attributes, and is in no way guarded against malicious attacks.
-
class
fsc.locker.
ConstLocker
(name, bases, attrs)¶ Locker metaclass setting
attr_mod_ctrl
to'all'
.
-
class
fsc.locker.
Locker
(name, bases, attrs)¶ Locker metaclass setting
attr_mod_ctrl
to'new'
.
-
class
fsc.locker.
OpenLocker
(name, bases, attrs)¶ Locker metaclass setting
attr_mod_ctrl
to'none'
.
-
class
fsc.locker.
SuperConstLocker
(name, bases, attrs)¶ Locker metaclass setting
attr_mod_ctrl
to'const'
.