aboutsummaryrefslogtreecommitdiff
path: root/rpkid/rpki
diff options
context:
space:
mode:
Diffstat (limited to 'rpkid/rpki')
-rw-r--r--rpkid/rpki/left_right.py28
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):