Recursively save any references and generic references on the document.
(self, **kwargs)
| 587 | return object_id, created |
| 588 | |
| 589 | def cascade_save(self, **kwargs): |
| 590 | """Recursively save any references and generic references on the |
| 591 | document. |
| 592 | """ |
| 593 | _refs = kwargs.get("_refs") or [] |
| 594 | |
| 595 | ReferenceField = _import_class("ReferenceField") |
| 596 | GenericReferenceField = _import_class("GenericReferenceField") |
| 597 | |
| 598 | for name, cls in self._fields.items(): |
| 599 | if not isinstance(cls, (ReferenceField, GenericReferenceField)): |
| 600 | continue |
| 601 | |
| 602 | ref = self._data.get(name) |
| 603 | if not ref or isinstance(ref, DBRef): |
| 604 | continue |
| 605 | |
| 606 | if not getattr(ref, "_changed_fields", True): |
| 607 | continue |
| 608 | |
| 609 | ref_id = f"{ref.__class__.__name__},{str(ref._data)}" |
| 610 | if ref and ref_id not in _refs: |
| 611 | _refs.append(ref_id) |
| 612 | kwargs["_refs"] = _refs |
| 613 | ref.save(**kwargs) |
| 614 | ref._changed_fields = [] |
| 615 | |
| 616 | @property |
| 617 | def _qs(self): |
no test coverage detected