[Zope] iteration through list with dtml-tags

Axel Bock news-and-lists at the-me.de
Wed Aug 7 10:51:59 EDT 2002

On Tue, 06 Aug 2002 20:24:19 +0200, John Hunter wrote:

> 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.

Well, no problem: 
I use a MySQL database connection through a Z Mysql Database Connection,
and I use this from my own product.

The code to access the database is partially stolen from Z SQL Method and
looks like this:

	self.connection = connection
		self.dbc = getattr(self, self.connection)
		return 'error'

To submit queries I do the following:

	DB = self.dbc()
	result = DB.query("select wuh from wobba")

"connection" is a reference to a Z MySQL Database Connection (I think), which I got
the following way (stolen from ... ):
		while self is not None:
			if hasattr(self, 'objectValues'):
				for o in self.objectValues():
					if (hasattr(o,'_isAnSQLConnection') and o._isAnSQLConnection
						and hasattr(o,'id')):
						if type(id) is not StringType: id=id()
						if not have_id(id):
							if hasattr(o,'title_and_id'): o=o.title_and_id()
				    			else: o=id
			if hasattr(self, 'aq_parent'): self=self.aq_parent
			else: self=None
		ids=map(lambda item: (item[1], item[0]), ids.items())
		return ids

Well, this is the way I do it right now.
I'm sorry if I give you a total overkill, but I truly have no clue how
this mechanism relly works, and I found absolutely no documentation from
the Zope site (which is a major flaw in Zope I think ...).

If you can comment something useful to this mess I would be quite happy,
otherwise ... well, it works ;-))

Bye, thanks and greetings, 


More information about the Python-list mailing list