Skip to content

audit_log: massive refactoring and cleanup

Skip R. requested to merge audit-log/refactoring-and-cleanup into master

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
  • removed request['_ctx_admin_id'] because we can use the id from request['ctx']
  • Action changes
    • renamed _id, _object, _before, _after, _get_object to remove leading _ for clearer code (is arguable)
    • renamed _obj to object in DeleteAction
    • renamed action.insert to action.update, directly use self.context.update
      • also refactored user code to take advantage of multiple kwargs instead of calling update() multiple times
      • reflects dict.update
    • renamed _text to details: 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 of action._ctx('stuff') is better and semantically makes more sense (same behavior though)
    • renamed full_text to render: 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__ for in operator to check if stuff is present in self.context (unused atm, but can be useful in the future)
    • diff_keys renamed to different_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 ()
    • iter_diff_keys renamed to different_keys_items and no longer @property
      • iter_ prefix is kinda 👎 imo
      • _items kinda goes hand in hand with dict.items() since this function yields keys and values just like dict.items()
  • 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 to DomainOwnerNotifyAction
    • name is better imo, "DomainBroadcast" might imply that something is broadcast to all user of that domain
Edited by Skip R.

Merge request reports