I'm trying to DRY my code.  I have a controller like this:

def myindex():
   import mymodule
   query = (db.sometable.is_active==True)
   select_fields = (db.sometable.id, db.sometable.name,
db.sometable.somefield)
   mymodule.myindex(request, session, db, query, selectfields)

Then, in mymodule.py

from html import A, TABLE, THEAD, TH, TR, TD, URL
from dal import DAL, Field, Table, Row, CALLABLETYPES

def myindex(request, session, db, query, selectfields)
  tbody = []
  rows = db(query).select(selectfields)
  fnames = []
  for f in selectfields:
    fnames.append(str(f).split('.')[-1]  # pulling out the field name
  for row in rows:
    print row # Diagnostic - this is not a real Row object, just a
list of fields
    tbody.append(row) ## EXCEPTION OCCURS HERE

I get a key error - can't find row.id
Can someone give a pointer to how to do this?
I suppose I can build the row set in my controller, but then it won't
be as DRY.

Reply via email to