Help with dbm TypeError

R

ryan

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 = dbm.open("Test","c")
next = 0
y['next'] = str(next)
y['next'] = str(int(y['next'])+1)
y['next'] '1'
y['next'] = str(int(y['next'])+1)
y['next']
'2'

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

Ryan Kaskel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,771
Messages
2,569,587
Members
45,097
Latest member
RayE496148
Top