本文整理汇总了Python中plone.app.multilingual.interfaces.ITranslationManager.add_translation_delegated方法的典型用法代码示例。如果您正苦于以下问题:Python ITranslationManager.add_translation_delegated方法的具体用法?Python ITranslationManager.add_translation_delegated怎么用?Python ITranslationManager.add_translation_delegated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.app.multilingual.interfaces.ITranslationManager
的用法示例。
在下文中一共展示了ITranslationManager.add_translation_delegated方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from plone.app.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.app.multilingual.interfaces.ITranslationManager import add_translation_delegated [as 别名]
def __call__(self):
language = self.request.get('language', None)
if language:
context = aq_inner(self.context)
translation_manager = ITranslationManager(context)
# if ILanguage(context).get_language() == LANGUAGE_INDEPENDENT:
# # XXX : Why we need this ? the subscriber from pm should
# maintain it
# language_tool = getToolByName(context, 'portal_languages')
# default_language = language_tool.getDefaultLanguage()
# ILanguage(context).set_language(default_language)
# translation_manager.update()
# context.reindexObject()
new_parent = translation_manager.add_translation_delegated(language) # noqa
registry = getUtility(IRegistry)
settings = registry.forInterface(IMultiLanguageExtraOptionsSchema)
sdm = self.context.session_data_manager
session = sdm.getSessionData(create=True)
session.set("tg", translation_manager.tg)
session.set("old_lang", ILanguage(self.context).get_language())
baseUrl = new_parent.absolute_url()
# We set the language and redirect to babel_view or not
if settings.redirect_babel_view:
# Call the ++addtranslation++ adapter to show the babel
# add form
url = '%s/++addtranslation++%s' % (
baseUrl, self.context.portal_type)
return self.request.response.redirect(url)
else:
# We look for the creation url for this content type
# Get the factory
types_tool = getToolByName(self.context, 'portal_types')
# Note: we don't check 'allowed' or 'available' here,
# because these are slow. We assume the 'allowedTypes'
# list has already performed the necessary calculations
actions = types_tool.listActionInfos(
object=new_parent,
check_permissions=False,
check_condition=False,
category='folder/add',
)
addActionsById = dict([(a['id'], a) for a in actions])
typeId = self.context.portal_type
addAction = addActionsById.get(typeId, None)
if addAction is not None:
url = addAction['url']
if not url:
url = '%s/createObject?type_name=%s' % (
baseUrl, quote_plus(typeId))
return self.request.response.redirect(url)
示例2: test_add_translation_delegated
# 需要导入模块: from plone.app.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.app.multilingual.interfaces.ITranslationManager import add_translation_delegated [as 别名]
def test_add_translation_delegated(self):
a_ca = createContentInContainer(
self.portal['ca'], 'Document', title=u"Test document")
translation_manager = ITranslationManager(a_ca)
portal_es = translation_manager.add_translation_delegated('es')
self.assertEqual(portal_es, self.portal['es'])
示例3: __call__
# 需要导入模块: from plone.app.multilingual.interfaces import ITranslationManager [as 别名]
# 或者: from plone.app.multilingual.interfaces.ITranslationManager import add_translation_delegated [as 别名]
def __call__(self):
language = self.request.get('language', None)
if language:
context = aq_inner(self.context)
translation_manager = ITranslationManager(context)
new_parent = translation_manager.add_translation_delegated(language) # noqa
baseUrl = new_parent.absolute_url()
url = '%s/++addtranslation++%s' % (baseUrl, IUUID(context))
return self.request.response.redirect(url)