瀏覽代碼

offer refactored way to remove subject collection

Bastien Sevajol 6 年之前
父節點
當前提交
b6ab205fb0
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      synergine2/simulation.py

+ 7 - 0
synergine2/simulation.py 查看文件

@@ -120,6 +120,13 @@ class Subject(IdentifiedObject):
120 120
         for collection in self.collections:
121 121
             self.simulation.collections.setdefault(collection, []).append(self.id)
122 122
 
123
+    def remove_collection(self, collection_name: str) -> None:
124
+        self.collections.remove(collection_name)
125
+        # Manipulate as shared property
126
+        simulation_collection = self.simulation.collections[collection_name]
127
+        simulation_collection.remove(self.id)
128
+        self.simulation.collections[collection_name] = simulation_collection
129
+
123 130
     def __str__(self):
124 131
         return self.__repr__()
125 132