def store(self,
              message,
              outputs,
              output_state,
              object_id,
              related_id=None):
        """Copies a dictionary or message to the state object of this address"""
        address = self.address(object_id=object_id, related_id=related_id)
        if address not in outputs:
            raise ValueError(
                "{} address {} for {} {} target {} was not sent as an output address"
                .format(self._name_title, address, self._name_id, object_id,
                        related_id))
        if address in output_state:
            container = output_state[address]
            store = self._find_in_state_container(
                container=container,
                address=address,
                object_id=object_id,
                related_id=related_id,
            )
            if not store:
                raise ValueError(
                    "{} store for {} {} target {} was not found in container".
                    format(self._name_title, self._name_id, object_id,
                           related_id))
        else:
            container, store = self._get_new_state()
            output_state[address] = container

        batcher.message_to_message(message_to=store,
                                   message_from=message,
                                   message_name=self._name_camel)
        output_state["changed"].add(address)
 def store_message(self, object_id, related_id, store, message, payload,
                   output_state):
     """Copies a message to the state object, excluding properties
     listed in message_fields_not_in_state property. This provides
     a simple default behavior for cases where this is appropriate;
     commonly override this method in message classes"""
     message_to_message(
         message_to=store,
         message_from=message,
         message_name=self._name_camel,
         exclude_fields=self.message_fields_not_in_state,
     )
 def message_to_storage(self, message):
     """Transforms the message into the state (storage) object"""
     return batcher.message_to_message(
         # pylint: disable=not-callable
         message_to=self._state_object(),
         message_from=message,
         message_name=self._name_camel,
         exclude_fields=self.message_fields_not_in_state,
     )
Example #4
0
 def message_to_storage(self, message):
     """Transforms the message into the state (storage) object"""
     # pylint: disable=not-callable
     return batcher.message_to_message(self._state_object(),
                                       self._name_camel, message)