本文整理汇总了Python中plone.multilingual.interfaces.ITranslationManager.get_restricted_translation方法的典型用法代码示例。如果您正苦于以下问题:Python ITranslationManager.get_restricted_translation方法的具体用法?Python ITranslationManager.get_restricted_translation怎么用?Python ITranslationManager.get_restricted_translation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.multilingual.interfaces.ITranslationManager
的用法示例。
在下文中一共展示了ITranslationManager.get_restricted_translation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_modified
# 需要导入模块: from plone.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.multilingual.interfaces.ITranslationManager import get_restricted_translation [as 别名]
def handle_modified(self, content):
fieldmanager = ILanguageIndependentFieldsManager(content)
if not fieldmanager.has_independent_fields():
return
sm = getSecurityManager()
try:
# Do we have permission to sync language independent fields?
if self.bypass_security_checks():
# Clone the current user and assign a new editor role to
# allow edition of all translated objects even if the
# current user whould not have permission to do that.
tmp_user = UnrestrictedUser(
sm.getUser().getId(), '', ['Editor', ], '')
# Wrap the user in the acquisition context of the portal
# and finally switch the user to our new editor
acl_users = getToolByName(content, 'acl_users')
tmp_user = tmp_user.__of__(acl_users)
newSecurityManager(None, tmp_user)
# Copy over all language independent fields
transmanager = ITranslationManager(content)
for translation in self.get_all_translations(content):
# PATCHED CODE HERE
trans_obj = transmanager.get_restricted_translation(translation)
if trans_obj:
if fieldmanager.copy_fields(trans_obj):
self.reindex_translation(trans_obj)
# END PATCHED CODE
finally:
# Restore the old security manager
setSecurityManager(sm)
示例2: translated_urls
# 需要导入模块: from plone.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.multilingual.interfaces.ITranslationManager import get_restricted_translation [as 别名]
def translated_urls(context):
manager = ITranslationManager(context)
translated_languages = manager.get_translated_languages()
content_language = ILanguage(context).get_language()
if content_language in translated_languages:
translated_languages.remove(content_language)
languages = []
for lang in translated_languages:
translation = manager.get_restricted_translation(lang)
if translation is not None:
term = SimpleVocabulary.createTerm(lang, lang,
translation.absolute_url())
languages.append(term)
return SimpleVocabulary(languages)