Ticket #8927 (new Bug)
Content Language negotiator fails to get the correct object when using a browser:page with the same id of an existing object
| Reported by: | erral | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 3.3.x |
| Component: | Internationalization | Version: | |
| Keywords: | Cc: |
Description
I have a multilingual website with the following structure (to simplify):
http://website/soluciones/producto1/subproducto1 -> Spanish language
http://website/solutions/product1/subproduct1 -> English language
I also have a browser view registered for objects of type subproduct called 'solutions', so I can have views like these:
http://website/soluciones/producto1/subproducto1/solutions
http://website/solutions/product1/subproduct1/solutions
The point is that when requesting http://website/soluciones/producto1/subproducto1/solutions the "unrestrictedTraverse" in the content language negotiator, traverses to /website/solutions and therefore gets its language (english), setting LANGUAGE to en instead of None (it should fail, because the view object has no Language attribute). Here is the pdb session that shows the bug:
(Pdb) l
26 contentpath = self.REQUEST.get('VIRTUAL_URL_PARTS')[1]
27 else:
28 contentpath = self.REQUEST.get('PATH_TRANSLATED')
29 import pdb;pdb.set_trace()
30
31 -> if contentpath is not None and contentpath.find('portal_factory') == -1:
32 obj = self.unrestrictedTraverse(contentpath, None)
33 if obj is not None:
34 if obj.Language() in self.getSupportedLanguages():
35 return obj.Language()
36 except ConflictError:
(Pdb) contentpath
'/ulma/productos/termoformado-y-blister/baby/solutions'
(Pdb) n
> /var/zope/downloads/eggs/cs.plt.contentnegotiator-1.3-py2.4.egg/cs/plt/contentnegotiator/patches.py(32)getPatchedContentLanguage()
-> obj = self.unrestrictedTraverse(contentpath, None)
(Pdb) n
> /var/zope/downloads/eggs/cs.plt.contentnegotiator-1.3-py2.4.egg/cs/plt/contentnegotiator/patches.py(33)getPatchedContentLanguage()
-> if obj is not None:
(Pdb) obj
<ATBTreeFolder at /ulma/solutions used for /ulma/productos/termoformado-y-blister/baby>
(Pdb) obj.Language()
'en'
(Pdb)

I hit preview but it seems that the bug was sent, agg.... This is the correct pdb session:
I'm using Plone 3.1.7 and 2.1 branch of PloneLanguageTool
2009-02-06 12:28:35 INFO Zope Ready to handle requests > /var/zope/instances/3192ulma/parts/svnproducts/PloneLanguageTool/LanguageTool.py(375)getContentLanguage() -> if contentpath is not None and contentpath.find('portal_factory') == -1: (Pdb) l 370 return [] 371 try: # This will actually work nicely with browserdefault as we get attribute error... 372 contentpath = self.REQUEST.get('PATH_TRANSLATED') 373 import pdb;pdb.set_trace() 374 375 -> if contentpath is not None and contentpath.find('portal_factory') == -1: 376 obj = self.unrestrictedTraverse(contentpath, None) 377 if obj is not None: 378 if obj.Language() in self.getSupportedLanguages(): 379 return obj.Language() 380 except ConflictError: (Pdb) contentpath '/ulma/productos/termoformado-y-blister/baby/solutions' (Pdb) n > /var/zope/instances/3192ulma/parts/svnproducts/PloneLanguageTool/LanguageTool.py(376)getContentLanguage() -> obj = self.unrestrictedTraverse(contentpath, None) (Pdb) n > /var/zope/instances/3192ulma/parts/svnproducts/PloneLanguageTool/LanguageTool.py(377)getContentLanguage() -> if obj is not None: (Pdb) obj <ATBTreeFolder at /ulma/solutions used for /ulma/productos/termoformado-y-blister/baby> (Pdb) obj.Language() 'en' (Pdb) baby = self.unrestrictedTraverse('/ulma/productos/termoformado-y-blister/baby') (Pdb) baby <Product at /ulma/productos/termoformado-y-blister/baby> (Pdb) baby.Language() 'es' (Pdb)