audit_log: massive refactoring and cleanup
i'm gay now
- tweak method names of
AuditLog
-
self._send_task_func
->self._sender
- likewise,
self._send_task
->self._sender_task
-
_actual_send
->_consume_and_process_queue
- uses
copy.copy
now
- uses
-
- removed
request['_ctx_admin_id']
because we can use the id fromrequest['ctx']
-
Action
changes- renamed
_id
,_object
,_before
,_after
,_get_object
to remove leading_
for clearer code (is arguable) - renamed
_obj
toobject
inDeleteAction
- renamed
action.insert
toaction.update
, directly useself.context.update
- also refactored user code to take advantage of multiple kwargs instead of calling
update()
multiple times - reflects
dict.update
- also refactored user code to take advantage of multiple kwargs instead of calling
- renamed
_text
todetails
: this makes it more clear that the stuff returned from this method will be the details of the action - removed
_ctx
in favor of having__getattr__
:action['stuff']
instead ofaction._ctx('stuff')
is better and semantically makes more sense (same behavior though) - renamed
full_text
torender
: a bit shorter while still meaning the same thing - merge all text rendering methods into
render
: i think that splitting them up into methods was unnecessary in this situation imo (code flow as kinda complicated for a method that only has a few branches) - also impl
__contains__
forin
operator to check if stuff is present inself.context
(unused atm, but can be useful in the future) -
diff_keys
renamed todifferent_keys
and no longer@property
- no longer being a property is arguable, but i removed it because it's kinda performs a calculation so it would be clearer to say that by forcing the user to put
()
- no longer being a property is arguable, but i removed it because it's kinda performs a calculation so it would be clearer to say that by forcing the user to put
-
iter_diff_keys
renamed todifferent_keys_items
and no longer@property
-
iter_
prefix is kinda👎 imo -
_items
kinda goes hand in hand withdict.items()
since this function yields keys and values just likedict.items()
-
- renamed
- renamed all
__Ctx
actions to__Action
(e.g.UserEditCtx
->UserEditAction
)- more consistent with the existing "Action" naming scheme
- creates a more consistent naming scheme for telling the person reading the code "this will push to the audit log queue"
- renamed
DomainBroadcastCtx
toDomainOwnerNotifyAction
- name is better imo, "DomainBroadcast" might imply that something is broadcast to all user of that domain
Edited by Skip R.