[Zope] iteration through list with dtml-tags
John Hunter
jdhunter at ace.bsd.uchicago.edu
Tue Aug 6 19:24:19 EDT 2002
>>>>> "Axel" == Axel Bock <news-and-lists at the-me.de> writes:
Axel> no, i think you did well understand the problem. But I do
Axel> not use ZSQL methods, and I am getting a list of tuples, as
Axel> I said. And these are not so easily dereferenced (cause
Axel> there are no names ... :-)
Axel> Up to now I came up with the following solution: <dtml-call
Axel> "REQUEST.set('something', sequence-item)"> Which I can
Axel> dereference as <dtml-var "something[x]">
Axel> I don't see another way. But you can tell me in which way I
Axel> can access a ZMySQLDatabaseconnection from within my own
Axel> product, if this is not too much a thing (I stole code from
Axel> ZSQLMethod and fiddled it until I could drop pure SQL
Axel> queries the form SQL.query("..."))
A little more info at this point would be helpful. What dbase are you
using and how are accessing it? Are you calling it from a python
product? If so, your dbase interface might have a mapping interface.
For example, MySQLdb has a cursors.DictCursor class which can br used
to get a dictionary rather than a tuple from a select call. You make
the connection like:
db = MySQLdb.connect(db='mydb',
host='myhost',
user='myuser',
passwd='mypass',
cursorclass=MySQLdb.cursors.DictCursor)
mh = MySQLTable(table_name='mytable', cursor=db.cursor())
A little more info on the dbase and python interface will help us
steer you toward the light.
John Hunter
More information about the Python-list
mailing list