Roundup Tracker - Issues

Issue 1512939

classification
Error while importing FileClass to anydbm backend
Type: Severity: normal
Components: None Versions:
process
Status: closed fixed
:
: : jonct, tkanka
Priority: normal :

Created on 2006-06-26 19:45 by tkanka, last changed 2006-08-02 18:29 by jonct.

Messages
msg2275 Author: [hidden] (tkanka) Date: 2006-06-26 19:45
I exported my database, tried to import it to another
tracker and got "TypeError: Integer keys only allowed
for Recno and Queue DB's". 

Roundup version is "1.1.2 (python 2.3.5)", and I'm
using Debian testing distribution. The used database
contains FileClass items and the target tracker uses
anydbm backend. 

The full traceback is here:
----
Traceback (most recent call last):
  File
"/usr/lib/python2.3/site-packages/roundup/admin.py",
line 1359, in run_command
    ret = function(args[1:])
  File
"/usr/lib/python2.3/site-packages/roundup/admin.py",
line 1171, in do_import
    cl.import_files(dir, nodeid)
  File
"/usr/lib/python2.3/site-packages/roundup/hyperdb.py",
line 899, in import_files
    mime_type = self.get(nodeid, 'type')
  File
"/usr/lib/python2.3/site-packages/roundup/backends/back_anydbm.py",
line 2075, in get
    return Class.get(self, nodeid, propname)
  File
"/usr/lib/python2.3/site-packages/roundup/backends/back_anydbm.py",
line 927, in get
    d = self.db.getnode(self.classname, nodeid)
  File
"/usr/lib/python2.3/site-packages/roundup/backends/back_anydbm.py",
line 331, in getnode
    if not db.has_key(nodeid):
  File "/usr/lib/python2.3/bsddb/__init__.py", line
142, in has_key
    return self.db.has_key(key)
TypeError: Integer keys only allowed for Recno and
Queue DB's
----

The error can be reproduced with the following script:

----
rm -rf tmp
mkdir tmp
roundup-admin -v
roundup-admin -i tmp/t1 install classic anydbm
mail_domain=localhost,mail_host=examplehost,tracker_web=http://localhost/tracker
roundup-admin -i tmp/t1 initialise pw
roundup-admin -i tmp/t1 create file name=test.txt
type='text/plain' content='some test text'
roundup-admin -i tmp/t1 export tmp/export
roundup-admin -i tmp/t2 install classic anydbm
mail_domain=localhost,mail_host=examplehost,tracker_web=http://localhost/tracker
roundup-admin -i tmp/t2 initialise pw
roundup-admin -i tmp/t2 import tmp/export
----

The roundup.admin.do_import explicitly converts nodeid
to integer and then it is given to anydbm backend which
accepts only  strings for keys. Should the ids always
be strings, or should the backends convert integers to
string when needed?
msg2276 Author: [hidden] (jonct) Date: 2006-08-02 18:29
Logged In: YES 
user_id=131905

See also
<http://sf.net/mailarchive/forum.php?thread_id=25618679&forum_id=966>

As you noted, one can't import into anydbm before either

    1) patching back_anydbm.py:getnode to accept nodeids
       expressed as integers
or
    2) patching admin.py:do_import to express nodeids as
       strings, e.g.  cl.import_files(dir, str(nodeid))

I ran into the same problem, and kept thinking the problem
was my data -- or that I was trying to upgrade 0.8->1.1.2.

But the same would happen to anyone trying to import data
into the anydbm backend.  If I'd realized that up front,
I wouldn't have used anydbm to test my conversion script.

So I repeat your findings in the hope it helps someone.  :)
History
Date User Action Args
2006-06-26 19:45:48tkankacreate