<div dir="ltr">Attached is a very simple patch to Modules/_bsddb.c which adds the ability for associate() callback functions to return lists of strings as opposed to just DB_DONOTINDEX or a single string.<br><br>I ran the normal tests (against BDB 4.6.21_p3-r1 on gentoo amd64) to ensure I haven't broken anything; I also replaced a few genre entries in test_associate.py with lists of genre strings to ensure that the library did not break when running the unit test again (which is the successful output shown below). While more detailed testing could be done to ensure that the secondary keys are being inserted correctly, I have confirmed that they are on a separate app that's using this module.<br>
<br>While I think BDB should be taking care of the allocated DBT memory thanks to DB_APPMALLOC based on the other code in this module and on a previous pure C module I wrote, I can't be 100% sure (I unfortunately don't have a whole lot of time to test in a more in-depth manner).<br>
<br>My apologies if there's a more formal way patches should be introduced and I missed it. I hope this is useful!<br>Eric<br><br># python setup.py build && python setup.py install && python test.py <br>
Found Berkeley DB 4.6 installation.<br> include files in /usr/include<br> library files in /usr/lib64<br> library name is libdb-4.6<br>running build<br>running build_py<br>running build_ext<br>building 'bsddb3._pybsddb' extension<br>
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPYBSDDB_STANDALONE=1 -I/usr/include -I/usr/local/include/python2.6 -c Modules/_bsddb.c -o build/temp.linux-x86_64-2.6/Modules/_bsddb.o<br>
gcc -pthread -shared build/temp.linux-x86_64-2.6/Modules/_bsddb.o -L/usr/lib64 -Wl,-R/usr/lib64 -ldb-4.6 -o build/lib.linux-x86_64-2.6/bsddb3/_pybsddb.so<br>Found Berkeley DB 4.6 installation.<br> include files in /usr/include<br>
library files in /usr/lib64<br> library name is libdb-4.6<br>running install<br>running build<br>running build_py<br>running build_ext<br>running install_lib<br>copying build/lib.linux-x86_64-2.6/bsddb3/_pybsddb.so -> /usr/local/lib/python2.6/site-packages/bsddb3<br>
running install_headers<br>running install_egg_info<br>Removing /usr/local/lib/python2.6/site-packages/bsddb3-4.7.3-py2.6.egg-info<br>Writing /usr/local/lib/python2.6/site-packages/bsddb3-4.7.3-py2.6.egg-info<br>Running tests from /home/username/Desktop/bsddb3-4.7.3/build<br>
<br>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<br>Berkeley DB 4.6.21: (October 2, 2008)<br>bsddb.db.version(): (4, 6, 21)<br>bsddb.db.__version__: 4.7.3<br>bsddb.db.cvsid: $Id: _bsddb.c 629 2008-10-03 12:48:06Z jcea $<br>
py module: /home/username/Desktop/bsddb3-4.7.3/build/lib.linux-x86_64-2.6/bsddb3/__init__.pyc<br>extension module: /home/username/Desktop/bsddb3-4.7.3/build/lib.linux-x86_64-2.6/bsddb3/_pybsddb.so<br>python version: 2.6 (r26:66714, Oct 13 2008, 12:39:03) <br>
[GCC 4.1.2 (Gentoo 4.1.2 p1.1)]<br>My pid: 8296<br>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<br>----------------------------------------------------------------------<br>Ran 318 tests in 45.226s<br>
<br>OK<br>#<br></div>