diff options
author | Rob Austein <sra@hactrn.net> | 2009-09-20 04:19:53 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2009-09-20 04:19:53 +0000 |
commit | 3270e95151a188f84aaeb737339a726ff2473278 (patch) | |
tree | f330051d3c8a440ab7f0067525f436ca58cdc2d9 | |
parent | 71f114e07a818f921fc2b2b3052179f3e133b17b (diff) |
Try a bit harder on handle fixup
svn path=/rpkid/rpki/left_right.py; revision=2778
-rw-r--r-- | rpkid/rpki/left_right.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/rpkid/rpki/left_right.py b/rpkid/rpki/left_right.py index 1bd7d192..1743660a 100644 --- a/rpkid/rpki/left_right.py +++ b/rpkid/rpki/left_right.py @@ -67,10 +67,24 @@ class data_elt(rpki.xml_utils.data_elt, rpki.sql.sql_persistent, left_right_name def make_reply_clone_hook(self, r_pdu): """ - Set self_handle when cloning. + Set handles when cloning. """ if r_pdu.self_handle is None: r_pdu.self_handle = self.self_handle + r_pdu.gctx = self.gctx + r_pdu.handle_fixup(self) + + def handle_fixup(self, q_pdu): + """ + Do _handle => _id translation. + """ + for tag, elt in self.handles: + id_name = tag + "_id" + if getattr(self, id_name, None) is None: + x = elt.serve_fetch_handle(self.gctx, self.self_id, getattr(q_pdu, tag + "_handle")) + if x is None: + raise rpki.exceptions.HandleTranslationError, "Could not translate %r %s_handle" % (self, tag) + setattr(self, id_name, getattr(x, id_name)) @classmethod def serve_fetch_handle(cls, gctx, self_id, handle): @@ -104,13 +118,7 @@ class data_elt(rpki.xml_utils.data_elt, rpki.sql.sql_persistent, left_right_name operations, self is the pre-existing object from SQL and q_pdu is the set request received from the the IRBE. """ - for tag, elt in self.handles: - id_name = tag + "_id" - if getattr(self, id_name, None) is None: - x = elt.serve_fetch_handle(self.gctx, self.self_id, getattr(q_pdu, tag + "_handle")) - if x is None: - raise rpki.exceptions.HandleTranslationError, "Could not translate %r %s_handle" % (self, tag) - setattr(self, id_name, getattr(x, id_name)) + self.handle_fixup(q_pdu) cb() class self_elt(data_elt): |