diff options
author | Ruan HE <ruan.he@orange.com> | 2015-11-27 13:27:21 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2015-11-27 13:27:22 +0000 |
commit | 9c8de66466e1e2259a4791576bd7b708c0323386 (patch) | |
tree | a7873ee22dc767c23d928c3e5dbd8711e9433996 | |
parent | 70b7bf12411b8fce302d0e29be8ec64581aa5e0a (diff) | |
parent | 094dec72ac6e3f5d3f08c0e3536b16b7b086bfee (diff) |
Merge "When deleting an intra-extension, deletion may be impossible due to foreign key constraints."
-rw-r--r-- | keystone-moon/keystone/contrib/moon/backends/sql.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/keystone-moon/keystone/contrib/moon/backends/sql.py b/keystone-moon/keystone/contrib/moon/backends/sql.py index 06071507..a2c8f5bc 100644 --- a/keystone-moon/keystone/contrib/moon/backends/sql.py +++ b/keystone-moon/keystone/contrib/moon/backends/sql.py @@ -292,12 +292,6 @@ class Rule(sql.ModelBase, sql.DictBase): __all_objects__ = ( - Subject, - Object, - Action, - SubjectCategory, - ObjectCategory, - ActionCategory, SubjectScope, ObjectScope, ActionScope, @@ -305,6 +299,12 @@ __all_objects__ = ( ObjectAssignment, ActionAssignment, SubMetaRule, + SubjectCategory, + ObjectCategory, + ActionCategory, + Subject, + Object, + Action, Rule, ) @@ -375,8 +375,8 @@ class IntraExtensionConnector(IntraExtensionDriver): for _object in __all_objects__: query = session.query(_object) query = query.filter_by(intra_extension_id=intra_extension_id) - _ref = query.first() - if _ref: + _refs = query.all() + for _ref in _refs: session.delete(_ref) session.flush() session.delete(ref) @@ -948,6 +948,8 @@ class IntraExtensionConnector(IntraExtensionDriver): intra_extension_dict = dict(ref.intra_extension) intra_extension_dict["aggregation_algorithm"] = aggregation_algorithm_id setattr(ref, "intra_extension", intra_extension_dict) + session.flush() + LOG.debug("set_aggregation_algorithm_id {}-{} {}".format(intra_extension_id, aggregation_algorithm_id, self.get_aggregation_algorithm_id(intra_extension_id))) return self.get_aggregation_algorithm_id(intra_extension_id) def del_aggregation_algorithm(self, intra_extension_id): |