From 9d1c503836dc2d67042cf0509bf0f97c913317d4 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sat, 5 Sep 2009 20:43:20 +0000 Subject: Simplify serve_pre_save_hook(). svn path=/rpkid/rpki/left_right.py; revision=2740 --- rpkid/rpki/left_right.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/rpkid/rpki/left_right.py b/rpkid/rpki/left_right.py index 1aaac024..3386a127 100644 --- a/rpkid/rpki/left_right.py +++ b/rpkid/rpki/left_right.py @@ -102,25 +102,15 @@ class data_elt(rpki.xml_utils.data_elt, rpki.sql.sql_persistent, left_right_name self and q_pdu may be the same object; when they are, this is a create operation, when they're not, this is a set operation and self is the pre-existing object from sql. - - I'm pretty sure that this method could become simpler. I have no - idea why we care about setting id values in r_pdu, and suspect - that was just confusion on my part. This version seems to work, - though, so I'm checking it in before attempting cleanup. """ for tag, elt in self.handles: id_name = tag + "_id" - if getattr(r_pdu, id_name, None) is not None: - continue - val = getattr(self, id_name, None) - if val is None: + if getattr(self, id_name, None) is None: handle_name = tag + "_handle" x = elt.serve_fetch_handle(self.gctx, self.self_id, getattr(q_pdu, handle_name)) if x is None: raise rpki.exceptions.HandleTranslationError, "Could not translate %r %r %r" % (handle_name, self, q_pdu) - val = getattr(x, id_name) - setattr(self, id_name, val) - setattr(r_pdu, id_name, val) + setattr(self, id_name, getattr(x, id_name)) cb() def unimplemented_control(self, *controls): -- cgit v1.2.3