def __init__(self, entities=None, allow_none_id=True):
        """
        :param bool allow_none_id: Flag specifying if calling :meth:`add`
            with an entity that does not have an ID is allowed.
        """
        # Flag indicating if None IDs are allowed in this cache.
        self.__allow_none_id = allow_none_id
        # List of cached entities. This is the only place we are holding a
        # real reference to the entity.
        if entities is None:
            entities = []
        self.__entities = entities
        # Dictionary mapping entity IDs to entities for fast lookup by ID.
        self.__id_map = WeakValueDictionary()
        # Dictionary mapping entity slugs to entities for fast lookup by slug.
        self.__slug_map = {}
def __init__ ( self , entities = None , allow_none_id = True ) : self . __allow_none_id = allow_none_id if entities is None : entities = [ ] self . __entities = entities self . __id_map = WeakValueDictionary ( ) self . __slug_map = { }
:param bool allow_none_id: Flag specifying if calling :meth:`add`
            with an entity that does not have an ID is allowed.