Help with dbm TypeError

ryan at ryan at
Mon Jan 9 15:55:38 EST 2006

I am writing a web application for mod_python that catalogs my home
(book) library. For now, I am using the Python dbm module to store
string representations of mod_python's req.form (using the
mod_python.publisher handler) using unique IDs as keys. In the .db
file, there is a key 'next' that holds the next key for the next form
submission. A TypeError exception is raised though when I attempt to
increment the 'next' key. This only occurs in mod_python.

This code...

    self._db['next'] = str(int(self._db['next'])+1)

raises this exception....

TypeError: string indices must be integers

>>> y ="Test","c")
>>> next = 0
>>> y['next'] = str(next)
>>> y['next'] = str(int(y['next'])+1)
>>> y['next']
>>> y['next'] = str(int(y['next'])+1)
>>> y['next']

I do not understand the cause of this exception. I am using Python
2.3.5. Any help would be greatly appreciated.

Ryan Kaskel

More information about the Python-list mailing list