[Python-bugs-list] [ python-Bugs-431597 ] Code being copied into shelve and UserDi
noreply@sourceforge.net
noreply@sourceforge.net
Sat, 09 Jun 2001 03:21:46 -0700
Bugs item #431597, was updated on 2001-06-09 03:21
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=431597&group_id=5470
Category: Python Library
Group: 3rd Party
Status: Open
Resolution: None
Priority: 5
Submitted By: Rick Jones (rjones33410)
Assigned to: Nobody/Anonymous (nobody)
Summary: Code being copied into shelve and UserDi
Initial Comment:
I've been writing a contacts program that uses a
UserDict as a direct interface to the record which is
then placed into a shelve. When I view the DB file
created by the shelve module I can see my code in the
Table.
This is a sample from the very start of the shelve
file, before the first record. This apears in the
begining like this no matter how many times I re-run
it with varying number of records.
•n}у Ў“Х}
€фЃt%vYачЃ€%v
CurKeys=db.keys()
Test=len(CurKeys)
Temp=1
NewList=[]
for list in CurKeys:
One=int(list)
NewList.append(One)
if Test in NewList:
Test=Test+1
Temp=Test
NextID='%s' % Temp
GetEntry=ThisEntry()
db[NextID]=GetEntry
print 'New Entry no.',NextID
db.close()
print 'Doneџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ
џџџџџџџџџџџџџџџџџџџџџџ
This is the method that is actually being looped.
You'll note at the end the shelve is closed after each
record is added yet only a single copy of the code.
I'm baffled as to how this can be? Not to mention it
copied the entire document/module without regard to
scope.
I discovered this when I did a record loop test to
stuff 1000 records into the shelve. I opened the file
to see if there were any noticable problems since I
don't know what kind of density the shelve can handle
and saw my code in the table along with the record I
looped in.
Now I figured I had somehow made the module scope a
variable that was being looped in with the record so I
went through the entire 1000 record entries and my
code only apears once, although it is somewhat broken
up and much more binary looking than my record.
I'm sure you can understand how much of a problem this
can be in a comercial app.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=431597&group_id=5470