当前位置: 首页>>代码示例>>Python>>正文


Python ITranslationManager.add_translation_delegated方法代码示例

本文整理汇总了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)
开发者ID:jianaijun,项目名称:plone.app.multilingual,代码行数:62,代码来源:translate.py

示例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'])
开发者ID:jianaijun,项目名称:plone.app.multilingual,代码行数:10,代码来源:test_api.py

示例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)
开发者ID:PythonUnited,项目名称:plone.app.multilingual,代码行数:11,代码来源:translate.py


注:本文中的plone.app.multilingual.interfaces.ITranslationManager.add_translation_delegated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。