当前位置: 首页>>代码示例>>Python>>正文


Python AuditLog.add方法代码示例

本文整理汇总了Python中grouper.models.audit_log.AuditLog.add方法的典型用法代码示例。如果您正苦于以下问题:Python AuditLog.add方法的具体用法?Python AuditLog.add怎么用?Python AuditLog.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grouper.models.audit_log.AuditLog的用法示例。


在下文中一共展示了AuditLog.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: log

# 需要导入模块: from grouper.models.audit_log import AuditLog [as 别名]
# 或者: from grouper.models.audit_log.AuditLog import add [as 别名]
    def log(
        self,
        authorization,  # type: Authorization
        action,  # type: str
        description,  # type: str
        on_user=None,  # type: Optional[str]
        on_group=None,  # type: Optional[str]
        on_permission=None,  # type: Optional[str]
        category=AuditLogCategory.general,  # type: AuditLogCategory
        date=None,  # type: Optional[datetime]
    ):
        # type: (...) -> None
        """Log an action to the audit log.

        Arguments don't cover all use cases yet.  This method will be expanded as further use cases
        are ported to this service.
        """
        actor = self._id_for_user(authorization.actor)
        if not date:
            date = datetime.utcnow()

        # We currently have no way to log audit log entries for objects that no longer exist.  This
        # should eventually be fixed via a schema change to use strings for all fields of the audit
        # log.  For now, we'll die with an exception.
        user = self._id_for_user(on_user) if on_user else None
        group = self._id_for_group(on_group) if on_group else None
        permission = self._id_for_permission(on_permission) if on_permission else None

        entry = AuditLog(
            actor_id=actor,
            log_time=date,
            action=action,
            description=description,
            on_user_id=user,
            on_group_id=group,
            on_permission_id=permission,
            category=int(category),
        )
        entry.add(self.session)

        # This should happen at the service layer, not the repository layer, but the API for the
        # plugin currently takes a SQL object.  This can move to the service layer once a data
        # transfer object is defined instead.
        self.plugins.log_auditlog_entry(entry)
开发者ID:dropbox,项目名称:grouper,代码行数:46,代码来源:audit_log.py


注:本文中的grouper.models.audit_log.AuditLog.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。