Exemplo n.º 1
0
    def __init__(self, owner):
        """
        Initialize the handler.
        """
        self.owner = owner
        self.events = {}

        object_key = owner.get_data_key()

        # Load events.
        event_records = event_mapper.get_object_event(object_key)

        for record in event_records:
            event = {}

            # Set data.
            event_type = record.type
            trigger_type = record.trigger_type

            for field in record._meta.fields:
                event[field.name] = record.serializable_value(field.name)
            event["type"] = event_type

            # Set additional data.
            event_additional = event_mapper.get_event_additional_data(
                event_type, event["key"])
            if event_additional:
                event.update(event_additional)

            if not trigger_type in self.events:
                self.events[trigger_type] = []
            self.events[trigger_type].append(event)
Exemplo n.º 2
0
    def __init__(self, owner, object_key=None):
        """
        Initialize the handler.
        """
        self.owner = owner
        self.events = {}

        if not object_key:
            object_key = owner.get_data_key()

        # Load events.
        event_records = event_mapper.get_object_event(object_key)

        for record in event_records:
            event = {}

            # Set data.
            event_action = record.action
            trigger_type = record.trigger_type

            for field in record._meta.fields:
                event[field.name] = record.serializable_value(field.name)
            event["action"] = event_action

            if not trigger_type in self.events:
                self.events[trigger_type] = []
            self.events[trigger_type].append(event)
Exemplo n.º 3
0
    def __init__(self, owner, object_key=None):
        """
        Initialize the handler.
        """
        self.owner = owner
        self.events = {}

        if not object_key:
            object_key = owner.get_data_key()

        # Load events.
        event_records = event_mapper.get_object_event(object_key)

        for record in event_records:
            event = {}

            # Set data.
            event_action = record.action
            trigger_type = record.trigger_type

            for field in record._meta.fields:
                event[field.name] = record.serializable_value(field.name)
            event["action"] = event_action

            if not trigger_type in self.events:
                self.events[trigger_type] = []
            self.events[trigger_type].append(event)
Exemplo n.º 4
0
def query_object_events(object_key):
    """
    Query all events of the given object.

    Args:
        object_key: (string) object' key.
    """
    fields = query_fields("event_data")
    records = get_object_event(object_key)
    rows = []
    for record in records:
        line = [str(record.serializable_value(field["name"])) for field in fields]
        rows.append(line)

    table = {
        "fields": fields,
        "records": rows,
    }

    return table
Exemplo n.º 5
0
def query_object_events(object_key):
    """
    Query all events of the given object.

    Args:
        object_key: (string) object' key.
    """
    fields = query_fields("event_data")
    records = get_object_event(object_key)
    rows = []
    for record in records:
        line = [str(record.serializable_value(field["name"])) for field in fields]
        rows.append(line)

    table = {
        "fields": fields,
        "records": rows,
    }

    return table