class Auditor(object): def __init__(self, siteInfo, user): if not siteInfo: m = 'No siteInfo' raise ValueError(m) self.siteInfo = siteInfo if not user: m = 'No userInfo' raise ValueError(m) if IGSUserInfo.providedBy(user): self.userInfo = user else: self.userInfo = IGSUserInfo(user) self.queries = AuditQuery() self.factory = AuditEventFactory() def info(self, code, instanceDatum='', supplementaryDatum=''): d = datetime.now(UTC) iD = to_ascii(instanceDatum) sD = to_ascii(supplementaryDatum) eventId = event_id_from_data(self.userInfo, self.userInfo, self.siteInfo, code, iD, sD) e = self.factory(self.userInfo.user, eventId, code, d, self.userInfo, None, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class Auditor(object): def __init__(self, context, siteInfo): self.siteInfo = siteInfo self.context = context self.queries = AuditQuery() self.factory = AuditEventFactory() def info(self, code, adminInfo, groupInfo=None, instanceDatum='', supplementaryDatum=''): d = now() eventId = to_id(to_unicode_or_bust(adminInfo.id) + unicode(d) + unicode(SystemRandom().randint(0, 1024)) + to_unicode_or_bust(adminInfo.name) + to_unicode_or_bust(self.siteInfo.id) + to_unicode_or_bust(self.siteInfo.name) + to_unicode_or_bust(code) + to_unicode_or_bust(instanceDatum) + to_unicode_or_bust(supplementaryDatum)) e = self.factory(self.context, eventId, code, d, adminInfo, None, self.siteInfo, groupInfo, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class WebPostAuditor(object): """An Auditor for ABEL findoc storage DESCRIPTION This auditor creates an audit trail for the ABEL findoc storage subsystem. The work of creating the actual events is then carried out by "FindocStorageAuditEventFactory". """ def __init__(self, context): """Create a user-creation auditor (after the act). """ self.context = context self.userInfo = createObject('groupserver.LoggedInUser', context) self.siteInfo = createObject('groupserver.SiteInfo', context) self.groupInfo = createObject('groupserver.GroupInfo', context) self.queries = AuditQuery() self.factory = WebPostAuditEventFactory() def info(self, code, instanceDatum='', supplementaryDatum=''): """Log an info event to the audit trail. DESCRIPTION This method logs an event to the audit trail. ARGUMENTS "code" The code that identifies the event. "instanceDatum" Data about the event. SIDE EFFECTS * Creates an ID for the new event, * Writes the instantiated event to the audit-table, and * Writes the event to the standard Python log. RETURNS None """ d = datetime.now(UTC) eventId = event_id_from_data(self.userInfo, self.userInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.context, eventId, code, d, self.userInfo, None, self.siteInfo, self.groupInfo, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class BounceHandlingAuditor(object): """An Auditor for GroupServer DESCRIPTION This auditor creates an audit trail for the handling of email bounces. The work of creating the actual events is then carried out by "BounceHandlingAuditEventFactory". """ def __init__(self, context, userInfo, groupInfo, siteInfo): """Create a bounce-handling auditor (after the act). """ self.context = context self.userInfo = userInfo self.groupInfo = groupInfo self.siteInfo = siteInfo self.queries = AuditQuery() self.factory = BounceHandlingAuditEventFactory() def info(self, code, instanceDatum='', supplementaryDatum=''): """Log an info event to the audit trail. DESCRIPTION This method logs an event to the audit trail. ARGUMENTS "code" The code that identifies the event. "instanceDatum" Data about the event. SIDE EFFECTS * Creates an ID for the new event, * Writes the instantiated event to the audit-table, and * Writes the event to the standard Python log. RETURNS None """ d = datetime.now(UTC) eventId = event_id_from_data(self.userInfo, self.userInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.context, eventId, code, d, None, self.userInfo, self.siteInfo, self.groupInfo, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class Auditor(object): def __init__(self, context): self.context = context self.queries = AuditQuery() self.factory = AuditEventFactory() def info(self, code, recipientUserInfo=None, instanceDatum=''): d = datetime.now(UTC) s = code + repr(recipientUserInfo) + instanceDatum + d.isoformat() eventId = to_id(s) e = self.factory( self.context, eventId, code, d, None, recipientUserInfo, None, None, instanceDatum, None, SUBSYSTEM) self.queries.store(e) log.info(e)
class Auditer(object): def __init__(self, userInfo, loggedInUserInfo, siteInfo): # --=mpj17=-- This is not a bug: what the audit-trail considers the # "user" is the person that is logged in. The "instance user" is the # person that is being acted on. self.userInfo = loggedInUserInfo self.instanceUserInfo = userInfo self.siteInfo = siteInfo self.queries = AuditQuery() self.factory = AuditEventFactory() def info(self, code, instanceDatum='', supplementaryDatum=''): d = datetime.now(UTC) eventId = event_id_from_data(self.userInfo, self.instanceUserInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.userInfo.user, eventId, code, d, self.userInfo, self.instanceUserInfo, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class Auditor(object): def __init__(self, context, siteInfo): self.siteInfo = siteInfo self.context = context self.queries = AuditQuery() self.factory = AuditEventFactory() def info(self, code, userInfo='', instanceDatum='', supplementaryDatum=''): d = datetime.now(UTC) i = userInfo and userInfo or self.siteInfo eventId = event_id_from_data(i, i, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.context, eventId, code, d, userInfo, userInfo, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class ChangeAuditor(object): def __init__(self, site): self.site = site self.userInfo = createObject('groupserver.LoggedInUser', site) self.siteInfo = createObject('groupserver.SiteInfo', site) self.queries = AuditQuery() self.factory = ChangeAuditEventFactory() def info(self, code, instanceDatum=''): d = datetime.now(UTC) eventId = event_id_from_data(self.userInfo, self.userInfo, self.siteInfo, code, instanceDatum, '') e = self.factory(self.site, eventId, code, d, self.userInfo, None, self.siteInfo, None, instanceDatum, None, SUBSYSTEM) self.queries.store(e) log.info(e)
class SiteMemberAuditor(object): def __init__(self, context, userInfo, siteInfo): self.context = context self.userInfo = userInfo self.siteInfo = siteInfo self.queries = AuditQuery() self.factory = AuditEventFactory() def info(self, code): d = datetime.now(UTC) eventId = event_id_from_data(self.userInfo, self.userInfo, self.siteInfo, code, '', str(d)) e = self.factory(self.context, eventId, code, d, self.userInfo, None, self.siteInfo, None, '', None, SUBSYSTEM) self.queries.store(e) log.info(e)
class foo(object): def __init__(self, user): self.user = user self.userInfo = createObject('groupserver.LoggedInUser', user) self.instanceUserInfo = IGSUserInfo(user) self.siteInfo = createObject('groupserver.SiteInfo', user) self.queries = AuditQuery() self.factory = CustomUserAuditEventFactory() def info(self, code, instanceDatum='', supplementaryDatum=''): d = date.today() eventId = event_id_from_data(self.userInfo, self.instanceUserInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.user, eventId, code, d, self.userInfo, self.instanceUserInfo, self.siteInfo, instanceDatum, supplementaryDatum) self.queries.store(e) log.info(e)
class AnonLoginAuditor(object): def __init__(self, context, siteInfo): self.context = context self.siteInfo = siteInfo self.userInfo = createObject('groupserver.UserFromId', context, '') self.queries = AuditQuery() self.factory = LoginAuditEventFactory() def info(self, code, instanceDatum='', supplementaryDatum=''): d = datetime.now(UTC) eventId = event_id_from_data(self.userInfo, self.userInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.userInfo.user, eventId, code, d, self.userInfo, None, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class Auditor(object): def __init__(self, siteInfo, userInfo): self.siteInfo = siteInfo self.userInfo = userInfo self.queries = AuditQuery() self.factory = AuditEventFactory() def info(self, code, groupInfo, adminInfo, instanceDatum='', supplementaryDatum=''): d = datetime.now(UTC) eventId = event_id_from_data(adminInfo, self.userInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.userInfo.user, eventId, code, d, adminInfo, self.userInfo, self.siteInfo, groupInfo, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class Auditor(object): def __init__(self, context, siteInfo): self.siteInfo = siteInfo self.context = context self.queries = AuditQuery() self.factory = AuditEventFactory() def info(self, code, instanceUserInfo='', instanceDatum = '', supplementaryDatum = ''): d = datetime.now(UTC) userInfo = createObject('groupserver.LoggedInUser', self.context) instanceUserInfo = instanceUserInfo and instanceUserInfo or userInfo eventId = event_id_from_data(userInfo, instanceUserInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.context, eventId, code, d, userInfo, instanceUserInfo, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class ProfileAuditer(object): def __init__(self, user): self.user = user self.userInfo = createObject('groupserver.LoggedInUser',user) self.instanceUserInfo = IGSUserInfo(user) self.siteInfo = createObject('groupserver.SiteInfo', user) self.queries = AuditQuery() self.factory = ProfileAuditEventFactory() def info(self, code, instanceDatum = '', supplementaryDatum = ''): d = datetime.now(UTC) eventId = event_id_from_data(self.userInfo, self.instanceUserInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.user, eventId, code, d, self.userInfo, self.instanceUserInfo, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class Auditor(object): def __init__(self, context, siteInfo): self.siteInfo = siteInfo self.context = context self.queries = AuditQuery() self.factory = AuditEventFactory() def info(self, code, instanceUserInfo='', instanceDatum='', supplementaryDatum=''): d = datetime.now(UTC) userInfo = createObject('groupserver.LoggedInUser', self.context) instanceUserInfo = instanceUserInfo and instanceUserInfo or userInfo eventId = event_id_from_data( userInfo, instanceUserInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory( self.context, eventId, code, d, userInfo, instanceUserInfo, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class LoginAuditor(object): """An Auditor for Login DESCRIPTION An auditor (sometimes called an auditer) creates an audit trail for a specific subsystem. In this case login. The work of creating the actual events is carried out by the audit-event factory, in this case "LoginAuditEventFactory". Every subsystem will (should) have its own auditor. """ def __init__(self, siteInfo, user): """Create an login auditor. DESCRIPTION The constructor for an auditor is passed all the data that will be the same for the events that are created during one use of the auditor by a Zope 3 page-view. ARGUMENTS "userInfo" "siteInfo" SIDE EFFECTS """ self.user = user self.userInfo = IGSUserInfo(user) self.siteInfo = siteInfo self.queries = AuditQuery() self.factory = LoginAuditEventFactory() def info(self, code, instanceDatum='', supplementaryDatum=''): """Log an info event to the audit trail. DESCRIPTION This method logs an event to the audit trail. It is named after the equivalent method in the standard Python logger, which it also writes to. The three arguments (other than self) are combined to form the arguments to the factory, which creates the event that is then recorded. ARGUMENTS "code" The code that identifies the event that is logged. Sometimes this is enough. "instanceDatum" Data about the event. Each event class has its own way to interpret this data. "supplementaryDatum" More data about an event. SIDE EFFECTS * Creates an ID for the new event, * Writes the instantiated event to the audit-table, and * Writes the event to the standard Python log. RETURNS None """ d = datetime.now(UTC) eventId = event_id_from_data(self.userInfo, self.userInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.userInfo.user, eventId, code, d, self.userInfo, None, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class LoginAuditor(object): """An Auditor for Login DESCRIPTION An auditor (sometimes called an auditer) creates an audit trail for a specific subsystem. In this case login. The work of creating the actual events is carried out by the audit-event factory, in this case "LoginAuditEventFactory". Every subsystem will (should) have its own auditor. """ def __init__(self, siteInfo, user): """Create an login auditor. DESCRIPTION The constructor for an auditor is passed all the data that will be the same for the events that are created during one use of the auditor by a Zope 3 page-view. ARGUMENTS "userInfo" "siteInfo" SIDE EFFECTS """ self.user = user self.userInfo = IGSUserInfo(user) self.siteInfo = siteInfo self.queries = AuditQuery() self.factory = LoginAuditEventFactory() def info(self, code, instanceDatum='', supplementaryDatum=''): """Log an info event to the audit trail. DESCRIPTION This method logs an event to the audit trail. It is named after the equivalent method in the standard Python logger, which it also writes to. The three arguments (other than self) are combined to form the arguments to the factory, which creates the event that is then recorded. ARGUMENTS "code" The code that identifies the event that is logged. Sometimes this is enough. "instanceDatum" Data about the event. Each event class has its own way to interpret this data. "supplementaryDatum" More data about an event. SIDE EFFECTS * Creates an ID for the new event, * Writes the instantiated event to the audit-table, and * Writes the event to the standard Python log. RETURNS None """ d = datetime.now(UTC) eventId = event_id_from_data(self.userInfo, self.userInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.userInfo.user, eventId, code, d, self.userInfo, None, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class PageEditAuditor(object): """An Auditor for Page Editor DESCRIPTION An auditor (sometimes called an auditer) creates an audit trail for a specific subsystem. In this case enrolment. The work of creating the actual events is carried out by the audit-event factory """ def __init__(self, page): """Create an edit auditor. DESCRIPTION The constructor for an auditor is passed all the data that will be the same for the events that are created during one use of the auditor by a Zope 3 page-view. ARGUMENTS "page" A IGSContentFolder representing the page being edited. SIDE EFFECTS The page is set to the page that is passed in, and used as the context for the auditor. The user (who is acting on the page) is set after determining the logged-in user, using the page as the context. The site that all this is occurring on is set, after being determined by a similar mechanism to the user. A page-edit audit event factory is instantiated. """ self.page = page self.userInfo = createObject('groupserver.LoggedInUser', page) self.siteInfo = createObject('groupserver.SiteInfo', page) self.queries = AuditQuery() self.factory = EditPageAuditEventFactory() def info(self, code, instanceDatum='', supplementaryDatum=''): """Log an info event to the audit trail. DESCRIPTION This method logs an event to the audit trail. It is named after the equivalent method in the standard Python logger, which it also writes to. ARGUMENTS "code" The code that identifies the event that is logged. Sometimes this is enough. "instanceDatum" The data to write as the instance datum for the event. Defaults to an empty string. (See below.) "supplementaryDatum" The data to write as the supplementary datum for the event. Defaults to an empty string. (See below.) If the instance datum *and* the supplementary datum are set to empty strings then they are set to the page URL and page title respectively. SIDE EFFECTS * Creates an ID for the new event, * Writes the instantiated event to the audit-table, and * Writes the event to the standard Python log. RETURNS None """ d = datetime.now(UTC) if ((not instanceDatum) and (not supplementaryDatum)): instanceDatum = self.page.absolute_url(0) supplementaryDatum = self.page.title_or_id() eventId = event_id_from_data(self.userInfo, self.userInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.page, eventId, code, d, self.userInfo, None, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)
class PageEditAuditor(object): """An Auditor for Page Editor DESCRIPTION An auditor (sometimes called an auditer) creates an audit trail for a specific subsystem. In this case enrolment. The work of creating the actual events is carried out by the audit-event factory """ def __init__(self, page): """Create an edit auditor. DESCRIPTION The constructor for an auditor is passed all the data that will be the same for the events that are created during one use of the auditor by a Zope 3 page-view. ARGUMENTS "page" A IGSContentFolder representing the page being edited. SIDE EFFECTS The page is set to the page that is passed in, and used as the context for the auditor. The user (who is acting on the page) is set after determining the logged-in user, using the page as the context. The site that all this is occurring on is set, after being determined by a similar mechanism to the user. A page-edit audit event factory is instantiated. """ self.page = page self.userInfo = createObject('groupserver.LoggedInUser', page) self.siteInfo = createObject('groupserver.SiteInfo', page) self.queries = AuditQuery() self.factory = EditPageAuditEventFactory() def info(self, code, instanceDatum='', supplementaryDatum=''): """Log an info event to the audit trail. DESCRIPTION This method logs an event to the audit trail. It is named after the equivalent method in the standard Python logger, which it also writes to. ARGUMENTS "code" The code that identifies the event that is logged. Sometimes this is enough. "instanceDatum" The data to write as the instance datum for the event. Defaults to an empty string. (See below.) "supplementaryDatum" The data to write as the supplementary datum for the event. Defaults to an empty string. (See below.) If the instance datum *and* the supplementary datum are set to empty strings then they are set to the page URL and page title respectively. SIDE EFFECTS * Creates an ID for the new event, * Writes the instantiated event to the audit-table, and * Writes the event to the standard Python log. RETURNS None """ d = datetime.now(UTC) if ((not instanceDatum) and (not supplementaryDatum)): instanceDatum = self.page.absolute_url(0) supplementaryDatum = self.page.title_or_id() eventId = event_id_from_data(self.userInfo, self.userInfo, self.siteInfo, code, instanceDatum, supplementaryDatum) e = self.factory(self.page, eventId, code, d, self.userInfo, None, self.siteInfo, None, instanceDatum, supplementaryDatum, SUBSYSTEM) self.queries.store(e) log.info(e)