Adds object auditing options to DefaultChannel.
This commit is contained in:
parent
06fe77a6ef
commit
c9ddef316f
1 changed files with 9 additions and 1 deletions
|
|
@ -221,7 +221,7 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
||||||
default=default, no_superuser_bypass=no_superuser_bypass)
|
default=default, no_superuser_bypass=no_superuser_bypass)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, key, *args, **kwargs):
|
def create(cls, key, account=None, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Creates a basic Channel with default parameters, unless otherwise
|
Creates a basic Channel with default parameters, unless otherwise
|
||||||
specified or extended.
|
specified or extended.
|
||||||
|
|
@ -230,6 +230,7 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
key (str): This must be unique.
|
key (str): This must be unique.
|
||||||
|
account (Account): Account to attribute this object to.
|
||||||
|
|
||||||
Kwargs:
|
Kwargs:
|
||||||
aliases (list of str): List of alternative (likely shorter) keynames.
|
aliases (list of str): List of alternative (likely shorter) keynames.
|
||||||
|
|
@ -238,6 +239,7 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
||||||
keep_log (bool): Log channel throughput.
|
keep_log (bool): Log channel throughput.
|
||||||
typeclass (str or class): The typeclass of the Channel (not
|
typeclass (str or class): The typeclass of the Channel (not
|
||||||
often used).
|
often used).
|
||||||
|
ip (str): IP address of creator (for object auditing).
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
channel (Channel): A newly created Channel.
|
channel (Channel): A newly created Channel.
|
||||||
|
|
@ -246,10 +248,16 @@ class DefaultChannel(with_metaclass(TypeclassBase, ChannelDB)):
|
||||||
"""
|
"""
|
||||||
errors = []
|
errors = []
|
||||||
obj = None
|
obj = None
|
||||||
|
ip = kwargs.pop('ip', '')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
kwargs['desc'] = kwargs.pop('description', '')
|
kwargs['desc'] = kwargs.pop('description', '')
|
||||||
obj = create.create_channel(key, *args, **kwargs)
|
obj = create.create_channel(key, *args, **kwargs)
|
||||||
|
|
||||||
|
# Record creator id and creation IP
|
||||||
|
if ip: obj.db.creator_ip = ip
|
||||||
|
if account: obj.db.creator_id = account.id
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
errors.append("An error occurred while creating this '%s' object." % key)
|
errors.append("An error occurred while creating this '%s' object." % key)
|
||||||
logger.log_err(exc)
|
logger.log_err(exc)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue