This is an automated email from the ASF dual-hosted git repository.

gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git

commit 14b39eeb394c8f5436ebe3c12cf5b0bd8d8633c8
Author: Greg Stein <[email protected]>
AuthorDate: Fri Sep 26 09:10:12 2025 -0500

    list_*() should return EasyDict objects
---
 v3/steve/election.py | 16 ++++++++++------
 v3/steve/persondb.py |  9 ++++++---
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/v3/steve/election.py b/v3/steve/election.py
index 4baa2a6..f621751 100644
--- a/v3/steve/election.py
+++ b/v3/steve/election.py
@@ -26,6 +26,7 @@ import sqlite3
 import pathlib
 
 import asfpy.db
+import easydict
 
 from . import crypto
 from . import vtypes
@@ -114,11 +115,10 @@ class Election:
         idata = ''.join(f'{i.iid}{i.title}{i.description}{i.type}{i.kv}'
                         for i in self.q_issues.fetchall())
 
+        # Include the PID and EMAIL for each Person.
         ### we don't want all people. Just those who are allowed to
         ### vote in this Election. Examine the "mayvote" table.
-        ### list_persons returns 3-tuples of (PID,NAME,EMAIL). We only
-        ### want pid/email in PDATA.
-        pdata = ''.join(p[0] + p[2] for p in pdb.list_persons())
+        pdata = ''.join(p.pid + p.email for p in pdb.list_persons())
 
         return (mdata + idata + pdata).encode()
 
@@ -188,11 +188,15 @@ class Election:
         self.c_delete_issue.perform(iid)
 
     def list_issues(self):
-        "Return ordered (IID, TITLE, DESCRIPTION, TYPE, KV) for all ISSUES."
+        "Return ordered EasyDicgt<IID, TITLE, DESCRIPTION, TYPE, KV> for all 
ISSUES."
 
         def extract_issue(row):
-            return (row.iid, row.title, row.description, row.type,
-                    self.json2kv(row.kv),)
+            return easydict.EasyDict(iid=row.iid,
+                                     title=row.title,
+                                     description=row.description,
+                                     type=row.type,
+                                     kv=self.json2kv(row.kv),
+                                     )
 
         self.q_issues.perform(self.eid)
         return [ extract_issue(row) for row in self.q_issues.fetchall() ]
diff --git a/v3/steve/persondb.py b/v3/steve/persondb.py
index 7b9acd0..4f9d7a5 100644
--- a/v3/steve/persondb.py
+++ b/v3/steve/persondb.py
@@ -22,6 +22,7 @@
 import pathlib
 
 import asfpy.db
+import easydict
 
 THIS_DIR = pathlib.Path(__file__).resolve().parent
 QUERIES = THIS_DIR.parent / 'queries.yaml'
@@ -63,8 +64,10 @@ class PersonDB:
         self.c_delete_person.perform(pid)
 
     def list_persons(self):
-        "Return ordered (PID, NAME, EMAIL) for each Person."
+        "Return ordered EasyDict<PID, NAME, EMAIL> for each Person."
 
+        ### switch to explicitly returning a generator?
+
+        # Run the query to completion, and return the entire list of Persons.
         self.q_person.perform()
-        return [ (row.pid, row.name, row.email)
-                 for row in self.q_person.fetchall() ]
+        return list(self.q_person.fetchall())

Reply via email to