﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
64	bug in Tub.registerReference when name provided	bgranger		"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.




"	defect	closed	major	0.2.8	unknown	0.2.5	fixed	Tub	
