From a4f9c94e6b3f2aadfbcc9ecd24dbf775f7a99f0e Mon Sep 17 00:00:00 2001
From: Rob Austein <sra@hactrn.net>
Date: Mon, 17 Sep 2007 04:02:46 +0000
Subject: Get "list" action working.

svn path=/scripts/rpki/left_right.py; revision=980
---
 scripts/rpkid.py | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

(limited to 'scripts/rpkid.py')

diff --git a/scripts/rpkid.py b/scripts/rpkid.py
index 483ad5be..fda7aed3 100755
--- a/scripts/rpkid.py
+++ b/scripts/rpkid.py
@@ -39,14 +39,23 @@ def left_right_handler(query, path):
     setattr(r_pdu, q_pdu.sql_template.index, getattr(q_pdu, q_pdu.sql_template.index))
     r_msg.append(r_pdu)
 
-  def get_handler():
+  def get_handler(q_pdu):
+    r_pdu = q_pdu.sql_fetch(db, cur, getattr(q_pdu, q_pdu.sql_template.index))
+    if r_pdu is not None:
+      make_reply(q_pdu, r_pdu)
+      r_msg.append(r_pdu)
+    else:
+      r_msg.append(make_error_report(q_pdu))
+
+  def set_handler(q_pdu):
     raise NotImplementedError
 
-  def set_handler():
-    raise NotImplementedError
-
-  def list_handler():
-    raise NotImplementedError
+  def list_handler(q_pdu):
+    for id in rpki.sql.get_column(db, cur, "SELECT %s FROM %s" % (q_pdu.sql_template.index, q_pdu.sql_template.table)):
+      r_pdu = q_pdu.sql_fetch(db, cur, id)
+      assert r_pdu is not None
+      make_reply(q_pdu, r_pdu)
+      r_msg.append(r_pdu)
 
   try:
     q_elt = decode(query, cms_ta_irbe)
-- 
cgit v1.2.3