''

def _recompute_all_models(self):

    new_all_models_set = set()
    for r in self.roots:
        new_all_models_set = new_all_models_set.union(r.references())
    old_all_models_set = set(self._all_models.values())
    to_detach = (old_all_models_set - new_all_models_set)
    to_attach = (new_all_models_set - old_all_models_set)
    recomputed = {}
    recomputed_by_name = MultiValuedDict()
    for m in new_all_models_set:
        recomputed[m._id] = m
        if (m.name is not None):
            recomputed_by_name.add_value(m.name, m)
    for d in to_detach:
        self._all_former_model_ids.add(d._id)
        d._detach_document()
    for a in to_attach:
        a._attach_document(self)
    self._all_models = recomputed
    self._all_models_by_name = recomputed_by_name
