[Pythonmac-SIG] dbm problems

Gordon Worley redbird@rbisland.cx
Mon, 31 Jul 2000 21:28:41 -0400


In my program, I'm importing shelve, which thereby imports anydbm. 
Everything works fine when my program is run from the IDE, but once 
built as a stand alone application, I get the following error upon 
trying to save a file:

ImportError:  no dbm clone found; tried ['dbhash', 'gdbm', 'dbm', 'dumbdbm']

Traceback (innermost last):

File "Wapplication.py", line 34, in mainloop
       self.do1event(mask, wait)
File "FrameWork.py", line 178, in do1event
       self.dispatch(event)
File "FrameWork.py", line 207, in dispatch
       handler(event)
File "FrameWork.py", line 265, in do_mouseDown
       handler(partcode, wid, event)
File "Wapplication.py", line 178, in do_inMenuBar
       self.do_rawmenu(id, item, window, event)
File "FrameWork.py", line 285, in do_rawmenu
       self.do_menu(id, item, window, event)
File "FrameWork.py", line 290, in do_menu
       self.menubar.dispatch(id, item, window, event)
File "Wapplication.py", line 410, in dispatch
       self.menus[id].dispatch(id, item, window, event)
File "Wapplication.py", line 427, in dispatch
       W.CallbackCall(callback, 0, id, item, window, event)
File "Wbase.py", line 684, in CallbackCall
       return callback()
File "rb_todo_manager.py", line 124, in domenu_save
       self.domenu_save_as()
File "rb_todo_manager.py", line 136, in domenu_save_as
       todo_file = shelve.open(self.file, "n")
File "shelve.py", line 157, in open
       return DbfilenameShelf(filename, flag)
File "shelve.py", line 146, in __init__
       import anydbm
File "anydbm.py", line 65, in ?
       raise ImportError, "no dbm clone found; tried %s" % _names

So, basically, from what I can tell, it can't find dbm or a dbm 
clone.  I tried importing dumbdbm (more on this in further down), but 
then saving files gave me back a "Mac OS Error:  -43, "File not 
found"" (<-- that's not literal, it might be missing parens and the 
capitalization could be wrong).  Also, the hash was divided into two 
files when saved (yes, the data writes but reports aforementioned 
error and the one currently being mentioned):  [filename].dat with 
the pickled contents of my objects, and [filename].dir with the keys. 
Why is this happening (i.e. what does this problem appear in built 
applications but not in scripts run from the IDE) and what can I do 
to work around it?

Now, you may be wondering why I'm importing dumbdbm.  In fact, in its 
own code it notes many bugs (which I have run into) and admits to 
being slow.  Well, it was the only dbm clone in the Lib folder. 
Actually, dbhash is there nominaly, but is just a wrapper for baddb, 
which is not present.

Now, just to make things more complicated, the program complaines 
(but only when built as an application) that no module named gdbm can 
be found when trying to open files.  Well, no kidding, gdbm is no 
where to be found, but why would anydbm want gdbm specifically when 
opening files?

Just to finish up, I haven't tried building my program as an applet, 
but this isn't what I want to do anyway.
-- 
Gordon Worley
http://www.rbisland.cx/
mailto:redbird@rbisland.cx
PGP:  C462 FA84 B811 3501 9010  20D2 6EF3 77F7 BBD3 B003