Bug? Traversable.absolute_url
Hi! I changes some stuff in my code and now I get: In self.absolute_url() Traceback (most recent call last): File "F:\zope2\lib\python\Products\StollDMS\StollFolder.py", line 454, in PrincipiaSearchSource Up to now only properties an MS-Word Documents can be searched File "F:\zope2\lib\python\Products\StollDMS\StollFolder.py", line 430, in check_stolldms_html return File "F:\zope2\lib\python\OFS\Traversable.py", line 48, in absolute_url return join([req['SERVER_URL']] + req._script + path, '/') KeyError: SERVER_URL Zope Version: (Zope 2.5.1 (binary release, python 2.1, win32-x86), python 2.1.3, win32) Python Version: 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] System Platform: win32 This happens with IE and Netscape6.1 Any hints? thomas
Hi Chris and all others! Chris Withers wrote:
Thomas Guettler wrote:
Hi!
I changes some stuff in my code and now I get:
What changes did you make?
I changed some stuff how objects get created. The way objects are created is a bit odd. There are defaults-Documents for each class. New objects get created by making a copy if the default objects I had an other strange error: hasattr(aq_base(self, prop)) behaved odd: It return true although the property was not there! Maybe someone finds a mistake in the way I create objects: BTW, it is not very important. Just have a look if you have time to. def createNewDocument(self, REQUEST=None): "Create a new document from the template in the folder 'defaults'" #Call __init__ of this class copy=self.__class__(self.root()) #Copy state to new instance state=self.__getstate__() id=copy.id # setstate overwrites id copy.__setstate__(state) copy.id=id copy.isDefaultDocument=0 copy._updateProperty('stollfolder_users', [self.root().userManagement. getCurrentUser()]) #Assertion: Test if the reference to the stollCatalog is OK if copy.default_catalog!=self.default_catalog: raise "Bad Copy" #Copy attachments for (id, att) in copy.objectItems(): new_att=att._getCopy(copy) copy._delObject(id) copy._setObject(id, new_att) r=copy.root() path=string.join(['/', r.id, '/documents/', copy.id], '') r.stollCatalog.catalog_object(copy, path) #Protokollierung copy.stollfolder_history=[] copy.stollfolder_historyAdd("Dokument Nr '" + copy.id + "' wurde erstellt") if REQUEST: REQUEST.RESPONSE.redirect('/' + self.root().id + '/documents/' + copy.id) return copy thomas
Thomas Guettler writes:
... In self.absolute_url()
Traceback (most recent call last): .. return join([req['SERVER_URL']] + req._script + path, '/') KeyError: SERVER_URL Almost surely, your "self" is not acquisition wrapped. This implies, that the request object is not reachable from it and "absolute_url" (which is dependent on the request object) fails.
You might use "getPhysicalPath" instead of "absolute_url", when you need a path independent from REQUEST. Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
Thomas Guettler