Exemple #1
0
 def _entity_related_entities(self, extent_name, oid):
     """Return a dictionary of related entity sets for an entity in
     `extent` with given OID."""
     entity_classes = self._entity_classes
     entity_map, extent_map = self._entity_extent_map(extent_name, oid)
     field_id_name = extent_map['field_id_name']
     entity_field_ids = extent_map['entity_field_ids']
     fields = entity_map['fields']
     related_entities = {}
     for field_id in entity_field_ids:
         # During database evolution, it may turn out that fields
         # get removed.  For time efficiency reasons, Schevo does
         # not iterate through all entities to remove existing
         # data.  Therefore, when getting entity fields from the
         # database here, ignore fields that exist in the entity
         # but no longer exist in the extent.
         field_name = field_id_name.get(field_id, None)
         if field_name:
             value = fields.get(field_id, None)
             if isinstance(value, tuple):
                 value = Placeholder.new(*value)
                 related_entities[field_name] = frozenset([value])
             else:
                 related_entities[field_name] = frozenset()
     return related_entities
Exemple #2
0
 def _entity_field(self, extent_name, oid, name):
     """Return the value of a field in an entity in named extent
     with given OID."""
     entity_map, extent_map = self._entity_extent_map(extent_name, oid)
     field_name_id = extent_map['field_name_id']
     entity_field_ids = extent_map['entity_field_ids']
     field_id = field_name_id[name]
     value = entity_map['fields'][field_id]
     if field_id in entity_field_ids and isinstance(value, tuple):
         value = Placeholder.new(*value)
     return value