#62 — redirect fails in conjunction with a concrete link
by
(anonymous)
—
last modified
Jul 09, 2009 03:34 PM
| State | Rejected |
|---|---|
| Version: | |
| Area | Functionality |
| Issue type | Bug |
| Severity | Medium |
| Submitted by | (anonymous) |
| Submitted on | Sep 12, 2006 |
| Responsible |
—
|
| Target release: |
—
|
Zope2.9.3 + python2.4.3 + Plone 2.1.2 + PloneLanguageTool 1.3 + LinguaPlone 0.9.0 - $Revision: 10093 $
There exists a folder-de, containing a page-de, and the translated folder-en, containing the translated page-en, and we add a link-object pointing to the url=http://localhost:8080/plonesite/folder-de/page-de.
Now if the overall portal-language is presently set to english, a klick on the link in the left navigation-portlet let display the page-de, and no redirect to the related translation page-en is done!
This happens since version 0.9.0 Revision 10093. With the former 0.9.0 beta r4895 and the 0.8.5 versions the mentioned redirect was done.
- Steps to reproduce:
- (language settings: available languages de and en, default language en)
1) create a simple plone-site
2) in the site-root 'contents' view add a folder with id 'deFolder' and set the language of this folder to de
3) translate the deFolder to en and give the id 'enFolder'
4) add a page with id 'dePage' to the deFolder and set the language of the new page to de
5) translate the dePage to en and give the is 'enPage'
6) add a Link with the url set to url=http://localhost:8080/plonesite/defolder/depage
Added by
Jarn
on
Sep 12, 2006 09:10 PM
It is correct that LP does not redirect anymore. You get what the URL says, which is intended behaviour.
Issue state:
unconfirmed
→
rejected
Added by
(anonymous)
on
Nov 30, 2006 08:51 PM
Why is this usefull behavior removed? Anyway i cant find a changelog entry about this?!?
Added by
Felix Kurth
on
Nov 30, 2006 10:55 PM
One way to reanable this function is to readd these functions to I18NBaseObject.pyWorks for me.
security.declarePrivate('setTranslateIfEditAndNonCanonical')
def setTranslateIfEditAndNonCanonical(self, stack):
"""Verifies if the requested template is the 'edit' one, if true
it updates the stack, injecting the 'translate' template.
This is only valid for non-canonical objects.
"""
if len(stack) == 1 and not self.isCanonical():
ti = self.getTypeInfo()
if config.IS_PLONE_2_0:
edit = ti and ti.getActionById('edit')
else:
edit = ti and ti.queryMethodID('edit')
if stack[0] in [edit, 'edit'] and \
getattr(self, 'translate_item', False):
stack[0] = 'translate_item'
self.REQUEST.set('default_tab', 'edit')
security.declarePrivate('traverseOrRedirect')
def traverseOrRedirect(self, language, stack):
"""Continues the traverse or start a redirect to the translation URL."""
translation = self.getTranslation(language)
language_tool = getToolByName(self, 'portal_languages')
if language_tool.force_language_urls:
self.REQUEST.RESPONSE.redirect(translation.absolute_url())
url_tool = getToolByName(self, 'portal_url')
path = url_tool.getRelativeContentPath(translation)
stack.extend(path[::-1])
def __before_publishing_traverse__(self, other, REQUEST):
"""A traverse hook to handle the following cases:
a) You go to the page, and have a browser language that is set
(no overriding cookie yet) -> it should pick up the language
if it exists. This is for portal, default view in folder and
a single page. If the page doesn't exist, the page in the URL
should be shown, and the language should be that language both
in the UI and in the content. It should set a cookie for this
language.
b) You have a cookie with language override set. -> it should
pick up the language from the cookie and display that. If
the translation doesn't exist, it should show the placeholder
page that says "This content is available in the following
translations: ...". The rule is that if a language is
explicitly set, we respect that until the user decides to
change it. In the case of the browser language setting
(previous use case), he has not set anything explicitly yet.
Content and UI languages should *always* be in sync, this is a
LinguaPlone basic policy... :)
"""
stack = REQUEST.get('TraversalRequestNameStack')
self.setTranslateIfEditAndNonCanonical(stack)
if not config.IS_PLONE_2_0:
DynamicType.__before_publishing_traverse__(self, other, REQUEST)
language_tool = getToolByName(self, 'portal_languages', None)
allowed_request_method = REQUEST.get('REQUEST_METHOD') in ['GET']
stack_has_content = stack and stack[-1] in self.objectIds() or False
create_translation = stack and stack[-1] == 'createTranslation' or False
if language_tool is None or not allowed_request_method or \
stack_has_content and not create_translation:
return
set_language = REQUEST.get('set_language')
cookie_lang = set_language or language_tool.getLanguageCookie()
content_lang = self.getLanguage()
current_lang = REQUEST.get('LANGUAGE')
if not cookie_lang:
if content_lang != current_lang:
if current_lang in self.getTranslationLanguages():
language_tool.setLanguageCookie(current_lang)
REQUEST.cookies.update({'I18N_LANGUAGE': current_lang})
self.traverseOrRedirect(current_lang, stack)
else:
language_tool.setLanguageCookie(content_lang)
REQUEST.cookies.update({'I18N_LANGUAGE': content_lang})
language_tool.setLanguageBindings()
else:
language_tool.setLanguageCookie(current_lang)
else:
if content_lang != current_lang:
if cookie_lang in self.getTranslationLanguages():
self.traverseOrRedirect(cookie_lang, stack)
else:
REQUEST.set('language', cookie_lang)
if not create_translation and content_lang and \
getattr(self, 'not_available_lang', False):
stack.append('not_available_lang')
No responses can be added.
If you can, please log in before submitting a reaction.
