diff options
author | Rob Austein <sra@hactrn.net> | 2009-09-20 05:16:53 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2009-09-20 05:16:53 +0000 |
commit | f95f3f1a54cbb484a7cb1529ba7b2224c10e3699 (patch) | |
tree | e9a5229368cc9c1e81b21154cdb173ea9b10f583 | |
parent | 3270e95151a188f84aaeb737339a726ff2473278 (diff) |
Doh, need to translate _id -> _handle, not the other way around.
svn path=/rpkid/rpki/left_right.py; revision=2779
-rw-r--r-- | rpkid/rpki/left_right.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/rpkid/rpki/left_right.py b/rpkid/rpki/left_right.py index 1743660a..4c6d8cbd 100644 --- a/rpkid/rpki/left_right.py +++ b/rpkid/rpki/left_right.py @@ -67,24 +67,18 @@ class data_elt(rpki.xml_utils.data_elt, rpki.sql.sql_persistent, left_right_name def make_reply_clone_hook(self, r_pdu): """ - Set handles when cloning. + Set handles when cloning, including _id -> _handle translation. """ 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)) + handle_name = tag + "_handle" + if getattr(r_pdu, handle_name, None) is None: + try: + setattr(r_pdu, handle_name, getattr(elt.sql_fetch(self.gctx, getattr(self, id_name)), handle_name)) + except AttributeError: + continue @classmethod def serve_fetch_handle(cls, gctx, self_id, handle): @@ -118,7 +112,13 @@ 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. """ - self.handle_fixup(q_pdu) + 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)) cb() class self_elt(data_elt): |