[Tutor] shelves behaving badly
Kent Johnson
kent37 at tds.net
Thu Aug 2 13:29:44 CEST 2007
Luke Jordan wrote:
> i've implemented a database as a shelve of record class instances. some
> of the fields in each record are dictionaries.
>
> i needed to parse info from 3 different reports into the dictionary
> fields in each record instance. i wrote the code to do this and tinkered
> it to fit the different reports (i.e. information being in different
> columns, etc.). for 2 of the reports, it runs fine. the required info
> turns up in the shelve after i run the code, and i can exit and reenter
> python, open the shelve, and it's all still there, where it should be.
> i've quadruple checked the code for the third report, and it looks like
> it should work. in fact it runs, and reports back that it did everything
> i told it to do; this includes checking results as they occur at
> runtime. however, when i reopen the shelve, none of that data is there.
> writeback is set to True, and I didn't forget to close the shelve at the
> end of my code.
>
> Now, if I open the shelve in the same shell as the script ran in, right
> after I run it, I get the updated shelve. but any other method of
> opening the shelve results in the shelve missing the data from the third
> report.
>
> Any ideas what's going on here?
It's pretty hard to say without seeing the code. I wonder if you are
saving the third shelve in a different location than you think you are,
and opening an old one in the other programs? Maybe check the full path
of the file you save (use os.path.abspath()) and check the modified date
of the one you open.
Kent
More information about the Tutor
mailing list