Post by d***@netzero.comEven on the earlier version which has none and empty dict values, everything was save
and restored properly.
I got exceptions because all of the priority fields had None, and so the database
code didn't create any form of column since it never saw an indirect form or a
value form. Then at insertion time it fell over because the column didn't exist
which raises an SQL error. I was real pleased that the transaction wrapper
caught that and did a rollback. Of course the problem then was that the
database had no sign of the table or values so I couldn't tell what it looked
like at the time of the exception :-)
Post by d***@netzero.comBut I followed your advice and cleaned out the dict of none and empty values.
Cool. You also don't need a version 4. Do what the phonebook code does.
If an index.idx exists it is read, saved to the database and renamed to
index-is-now-in-database.bak. If it doesn't exist then the database
is read.
Users can get back the state before the upgrade by renaming the .bak
file to index.idx.
My one tree where I kept getting the error is under open heart surgery at
the moment for the wallpaper/ringtone code. On my other tree I keep getting
the following exception. The index.idx is attached.
File "/home/space/bitpim/bpcalendar.py", line 733, in getfromfs
self.CURRENTFILEVERSION)
File "/home/space/bitpim/common.py", line 187, in readversionedindexfile
versionhandlerfunc(dict, version)
File "/home/space/bitpim/bpcalendar.py", line 794, in versionupgrade
dict['result']['calendar']=self.convert_dict(dict['result'].get('calendar', {}), 3, 4)
File "/home/space/bitpim/bpcalendar.py", line 810, in convert_dict
return self.__convert3to4(dict, ringtone_index)
File "/home/space/bitpim/bpcalendar.py", line 822, in __convert3to4
r[k]['start']='%04d%02d%02dT%02d%02d'%\
TypeError: unsubscriptable object
Frame getfromfs in /home/space/bitpim/bpcalendar.py at line 733
dct = Keys ['__builtins__', 'result']
{'__builtins__': {'help': Type help() for interactive help, or help(object) for
dict = Keys ['categories', 'phonebook', 'ringtone-index', 'wallpaper-index']
{'phonebook': {}, 'wallpaper-index': {1: {'origin': 'builtin', 'name': 'Balloons
self = <bpcalendar.Calendar; proxy of C++ wxPanel instance at _28946208_p_wxPanel>
Frame readversionedindexfile in /home/space/bitpim/common.py at line 187
currentversion = 4
versionhandlerfunc = <bound method Calendar.versionupgrade of <bpcalendar.Calendar; proxy of C++ wxPa
version = 2
dict = Keys ['__builtins__', 'result']
{'__builtins__': {'help': Type help() for interactive help, or help(object) for
filename = u'/home/rogerb/.bitpim-files/calendar/index.idx'
Frame versionupgrade in /home/space/bitpim/bpcalendar.py at line 794
self = <bpcalendar.Calendar; proxy of C++ wxPanel instance at _28946208_p_wxPanel>
version = 4
dict = Keys ['__builtins__', 'result']
{'__builtins__': {'help': Type help() for interactive help, or help(object) for
Frame convert_dict in /home/space/bitpim/bpcalendar.py at line 810
to_version = 4
ringtone_index = Keys []
{}
self = <bpcalendar.Calendar; proxy of C++ wxPanel instance at _28946208_p_wxPanel>
dict = Keys ['098173935ee8310d598f143d07be37a76020ff57', '0a663b0d820ca81455de3fed5f028a0948651e5a',
'0b6c71565dcef4069904c368d10419da01a9624a', '120048c86ad42a6c1aa3d8655dfb6385024f8a4e', '1ec389918218e588dd36654279a0374de01a9dab',
'25bc6b258da652e83126a88b8d374b11510f32c8', '4375de2acd14490539ca6b892c4e68c5813eccff', '570f0909be00c56594bf50aa471e8ceaf95aa14b',
'5be39c0199ad222d3c8fa2a5338a2b031c42ed5f', '8174e03f732096c68ae1a283f0b6727c91032d35', '9c9b3bcb7ff3082589abcf25abe80ed790e408ec',
'b939b479822d9fdfbf290d5d521029cf1a915d6d', 'ce6449851918c9906c3b05e1d327534181769b28', 'dd7d64e8f21ac48cc4c53249aa6a715b2288f418',
'ec7ba2d7d687ebde8af4ddea75d209429f083645', 'fc4e9e1b6a4203d1237f4b33ac6b01a6cebeecd8']
{'fc4e9e1b6a4203d1237f4b33ac6b01a6cebeecd8': <bpcalendar.CalendarEntry object at
from_version = 3
Frame __convert3to4 in /home/space/bitpim/bpcalendar.py at line 822
ringtone_index = Keys []
{}
e = <bpcalendar.CalendarEntry object at 0x423e4aec>
k = 'fc4e9e1b6a4203d1237f4b33ac6b01a6cebeecd8'
r = Keys ['fc4e9e1b6a4203d1237f4b33ac6b01a6cebeecd8']
{'fc4e9e1b6a4203d1237f4b33ac6b01a6cebeecd8': <bpcalendar.CalendarEntry object at
dict = Keys ['098173935ee8310d598f143d07be37a76020ff57', '0a663b0d820ca81455de3fed5f028a0948651e5a',
'0b6c71565dcef4069904c368d10419da01a9624a', '120048c86ad42a6c1aa3d8655dfb6385024f8a4e', '1ec389918218e588dd36654279a0374de01a9dab',
'25bc6b258da652e83126a88b8d374b11510f32c8', '4375de2acd14490539ca6b892c4e68c5813eccff', '570f0909be00c56594bf50aa471e8ceaf95aa14b',
'5be39c0199ad222d3c8fa2a5338a2b031c42ed5f', '8174e03f732096c68ae1a283f0b6727c91032d35', '9c9b3bcb7ff3082589abcf25abe80ed790e408ec',
'b939b479822d9fdfbf290d5d521029cf1a915d6d', 'ce6449851918c9906c3b05e1d327534181769b28', 'dd7d64e8f21ac48cc4c53249aa6a715b2288f418',
'ec7ba2d7d687ebde8af4ddea75d209429f083645', 'fc4e9e1b6a4203d1237f4b33ac6b01a6cebeecd8']
{'fc4e9e1b6a4203d1237f4b33ac6b01a6cebeecd8': <bpcalendar.CalendarEntry object at
self = <bpcalendar.Calendar; proxy of C++ wxPanel instance at _28946208_p_wxPanel>
Roger