84 # NOTE: we can't use entity.rest_path() at this point because |
84 # NOTE: we can't use entity.rest_path() at this point because |
85 # rest_path() could rely on schema constraints (such as a required |
85 # rest_path() could rely on schema constraints (such as a required |
86 # relation) that might not be satisfied yet (in case of creations) |
86 # relation) that might not be satisfied yet (in case of creations) |
87 if not self._edited_entity: |
87 if not self._edited_entity: |
88 self._edited_entity = entity |
88 self._edited_entity = entity |
89 |
|
90 # XXX move to EditController (only customer) |
|
91 def delete_entities(self, eidtypes): |
|
92 """delete entities from the repository""" |
|
93 redirect_info = set() |
|
94 eidtypes = tuple(eidtypes) |
|
95 for eid, etype in eidtypes: |
|
96 entity = self._cw.entity_from_eid(eid, etype) |
|
97 path, params = entity.after_deletion_path() |
|
98 redirect_info.add( (path, tuple(params.iteritems())) ) |
|
99 entity.delete() |
|
100 if len(redirect_info) > 1: |
|
101 # In the face of ambiguity, refuse the temptation to guess. |
|
102 self._after_deletion_path = 'view', () |
|
103 else: |
|
104 self._after_deletion_path = iter(redirect_info).next() |
|
105 if len(eidtypes) > 1: |
|
106 self._cw.set_message(self._cw._('entities deleted')) |
|
107 else: |
|
108 self._cw.set_message(self._cw._('entity deleted')) |
|
109 |
89 |
110 def validate_cache(self, view): |
90 def validate_cache(self, view): |
111 view.set_http_cache_headers() |
91 view.set_http_cache_headers() |
112 self._cw.validate_cache() |
92 self._cw.validate_cache() |
113 |
93 |