Opened 17 years ago

Last modified 16 years ago

#64 closed defect

bug in Tub.registerReference when name provided — at Initial Version

Reported by: bgranger Owned by:
Priority: major Milestone: 0.2.8
Component: unknown Version: 0.2.5
Keywords: Tub Cc:

Description

The following call doesn't work:

mytub.registerReference(fooo, 'fooname', furlFile='foo.furl')

If foo.furl already exists. This is because in registerReference, there is code:

oldfurl = None if furlFile:

try:

oldfurl = open(furlFile, "r").read().strip()

except EnvironmentError?:

pass

if oldfurl:

if name is None:

sr = SturdyRef?(oldfurl) name = sr.name

if self.tubID != sr.tubID: # problem occurs here!!!

raise WrongTubIdError?("I cannot keep using the old FURL (%s)"

" because it does not have the same" " TubID as I do (%s)" % (oldfurl, self.tubID))

If there is an existing furlFile (oldfurl == True), but there is a name set, no local object called sr gets created and an exception is raised.

The following seems to fix the problem:

oldfurl = None if furlFile:

try:

oldfurl = open(furlFile, "r").read().strip()

except EnvironmentError?:

pass

if oldfurl:

sr = SturdyRef?(oldfurl) if name is None:

name = sr.name

if self.tubID != sr.tubID:

raise WrongTubIdError?("I cannot keep using the old FURL (%s)"

" because it does not have the same" " TubID as I do (%s)" % (oldfurl, self.tubID))

By moving the creation of sr outside the if name is None test, the sr object gets created no matter what so it is available in the subsequent if self.tubID != sr.tubID test.

Change History (0)

Note: See TracTickets for help on using tickets.