old_contents: import mongoengine
  
  
  class BrokerStruct(object):
      """
      Copy the data out of a mongoengine.Document, including nested Documents,
      but do not copy any of the mongo-specific methods or attributes.
      """
      def __init__(self, mongo_document):
          """
          Parameters
          ----------
          mongo_document : mongoengine.Document
          """
          self._name = mongo_document.__class__.__name__
          fields = mongo_document._fields
          for field in fields:
              attr = getattr(mongo_document, field)
              if isinstance(attr, mongoengine.Document):
                  attr = BrokerStruct(attr)
              setattr(self, field, attr)
  
      def __repr__(self):
          return "<BrokerStruct {0}>".format(self._name)
  
new_contents: import mongoengine
  import datetime
  
  class BrokerStruct(object):
      """
      Copy the data out of a mongoengine.Document, including nested Documents,
      but do not copy any of the mongo-specific methods or attributes.
      """
      def __init__(self, mongo_document):
          """
          Parameters
          ----------
          mongo_document : mongoengine.Document
          """
          self._name = mongo_document.__class__.__name__
          fields = mongo_document._fields
          for field in fields:
              attr = getattr(mongo_document, field)
              if isinstance(attr, mongoengine.Document):
                  attr = BrokerStruct(attr)
              setattr(self, field, attr)
              # For debugging, add a human-friendly time_as_datetime attribute.
              if hasattr(self, 'time'):
                  self.time_as_datetime = datetime.datetime.fromtimestamp(self.time)
  
      def __repr__(self):
          return "<BrokerStruct {0}>".format(self._name)
  
subject: Add time_as_datetime for debugging.