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


Python IViewView.providedBy方法代码示例

本文整理汇总了Python中plone.app.layout.globals.interfaces.IViewView.providedBy方法的典型用法代码示例。如果您正苦于以下问题:Python IViewView.providedBy方法的具体用法?Python IViewView.providedBy怎么用?Python IViewView.providedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plone.app.layout.globals.interfaces.IViewView的用法示例。


在下文中一共展示了IViewView.providedBy方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_portlet_inheritance

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
    def test_portlet_inheritance(self):
        portal = self.layer['portal']
        folder = portal.folder2
        request = folder.REQUEST
        view = folder.restrictedTraverse('@@plone')
        alsoProvides(view, IViewView)
        self.assertTrue(IViewView.providedBy(view))
        viewlet_manager = queryMultiAdapter(
            (folder, request, view),
            IContentProvider,
            'plone.abovecontentbody')
        viewlet = queryMultiAdapter(
            (folder, request, view, viewlet_manager),
            IViewlet,
            'collective.calltoaction')
        self.assertTrue(viewlet is not None)
        viewlet.update()
        # The portlet from the test fixture is blocked.
        self.assertEqual(len(viewlet.data), 0)

        # Show the action globally.  This ignores portlet inheritance.
        registry = getUtility(IRegistry)
        settings = registry.forInterface(
            ICollectiveCalltoactionSettings, check=False)
        self.assertFalse(settings.show_global)
        settings.show_global = True

        # Now we should see the portlet
        viewlet.update()
        self.assertEqual(len(viewlet.data), 1)
开发者ID:collective,项目名称:collective.calltoaction,代码行数:32,代码来源:test_viewlet.py

示例2: available

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
    def available(self):
        if not (IViewView.providedBy(self.view)
                or IFolderContentsView.providedBy(self.view)):
            return False

        # Context could be a default page.  We want the canonical object
        # instead.
        context = aq_inner(self.context)
        pcs = getMultiAdapter(
            (context, self.request), name='plone_context_state')
        canonical = pcs.canonical_object()
        if not IQuickUploadCapable.providedBy(canonical):
            return False
        elif IQuickUploadNotCapable.providedBy(canonical):
            return False
        elif not self.pm.checkPermission('Add portal content', canonical):
            return False
        elif isTemporary(canonical):
            return False

        upload_portal_type = self.data.upload_portal_type
        if (upload_portal_type and upload_portal_type != 'auto'
                and upload_portal_type not in [
                    t.id for t in canonical.getAllowedTypes()
                ]):
            return False
        else:
            return True
开发者ID:collective,项目名称:collective.quickupload,代码行数:30,代码来源:quickuploadportlet.py

示例3: test_viewlet

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
 def test_viewlet(self):
     request = self.folder.REQUEST
     view = self.folder.restrictedTraverse('@@plone')
     alsoProvides(view, IViewView)
     self.assertTrue(IViewView.providedBy(view))
     viewlet_manager = queryMultiAdapter(
         (self.folder, request, view),
         IContentProvider,
         'plone.abovecontentbody')
     viewlet = queryMultiAdapter(
         (self.folder, request, view, viewlet_manager),
         IViewlet,
         'collective.calltoaction')
     self.assertTrue(viewlet is not None)
     viewlet.update()
     # We expect data from the portlet assignment in
     # profiles/testfixture/portlets.xml.
     self.assertEqual(len(viewlet.data), 1)
     portlet = viewlet.data[0]
     self.assertIn('assignment', portlet.keys())
     self.assertIn('html', portlet.keys())
     assignment = portlet['assignment']
     self.assertEqual(assignment.milli_seconds_until_overlay, 1000)
     portlet_html = portlet['html']
     self.assertIn('portletCallToAction', portlet_html)
     self.assertIn('portletCallToAction', portlet_html)
     viewlet_html = viewlet.render()
     self.assertIn(portlet_html, viewlet_html)
     self.assertIn('data-timeout="1000"', viewlet_html)
开发者ID:collective,项目名称:collective.calltoaction,代码行数:31,代码来源:test_viewlet.py

示例4: get_viewlet

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
def get_viewlet(context=None, request=None, manager=None, name=None):
    """Helper method for getting the viewlet for the provided viewlet name
    and viewlet manager.

    :param context: context object
    :param request: request
    :param manager: viewlet manager, for which the viewlet is registered
    :param name: viewlet name
    :returns: viewlet, if found, None otherwise
    """

    # viewlet managers also require a view object for adaptation
    view = BrowserView(context, request)
    if not IViewView.providedBy(view):
        alsoProvides(view, IViewView)

    # viewlet managers are found by Multi-Adapter lookup
    manager = getMultiAdapter(
        (context, request, view), IViewletManager, manager)

    # calling update() on a manager causes it to set up its viewlets
    manager.update()

    all_viewlets = manager.viewlets
    for viewlet in all_viewlets:
        if viewlet.__name__ == name:
            return viewlet
开发者ID:termitnjak,项目名称:tribuna.content,代码行数:29,代码来源:viewlet.py

示例5: update

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
 def update(self):
     super(ToolbarViewlet, self).update()
     if IViewView.providedBy(self.__parent__):
         # Ensure this viewlet has the interface that the iterate
         # alert viewlets are registered against such that they
         # only show up on view, not on edit.
         alsoProvides(self, IViewView)
开发者ID:rpatterson,项目名称:plone.app.toolbar,代码行数:9,代码来源:bbb.py

示例6: show_history

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
 def show_history(self):
     if not _checkPermission('CMFEditions: Access previous versions', self.context):
         return False
     if IViewView.providedBy(self.__parent__):
         return True
     if IFolderContentsView.providedBy(self.__parent__):
         return True
     return False
开发者ID:joemariedimzon,项目名称:wccminisites.policy,代码行数:10,代码来源:document_byline.py

示例7: update

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
    def update(self):
        # The drop-down menus are pulled in via a simple content provider
        # from plone.app.contentmenu. This behaves differently depending on
        # whether the view is marked with IViewView. If our parent view
        # provides that marker, we should do it here as well.
        super(ContentViewsViewlet, self).update()
        if IViewView.providedBy(self.__parent__):
            alsoProvides(self, IViewView)

        self.tabSet1, self.tabSet2 = self.getTabSets()
开发者ID:zopyx,项目名称:plone.app.layout,代码行数:12,代码来源:common.py

示例8: mark_view

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
    def mark_view(self, view):
        """Adds a marker interface to the view if it is "the" view for the
        context May only be called from a template.
        """
        if not view:
            return

        context_state = getMultiAdapter((self.context, self.request), name=u"plone_context_state")

        if context_state.is_view_template() and not IViewView.providedBy(view):
            alsoProvides(view, IViewView)
开发者ID:urska19,项目名称:Plone-test,代码行数:13,代码来源:layout.py

示例9: update

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
    def update(self):
        context = aq_inner(self.context)
        context_state = getMultiAdapter((context, self.request),
                                        name=u'plone_context_state')

        self.object_actions = context_state.actions('object_actions')

        # The drop-down menus are pulled in via a simple content provider
        # from plone.app.contentmenu. This behaves differently depending on
        # whether the view is marked with IViewView. If our parent view
        # provides that marker, we should do it here as well.
        if IViewView.providedBy(self.__parent__):
            alsoProvides(self, IViewView)
开发者ID:collective,项目名称:plonetheme.responsive1140,代码行数:15,代码来源:common.py

示例10: test_viewlet_only_on_view

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
 def test_viewlet_only_on_view(self):
     # When the view is not on IViewView, the viewlet is not registered.
     request = self.folder.REQUEST
     view = self.folder.restrictedTraverse('@@plone')
     self.assertFalse(IViewView.providedBy(view))
     viewlet_manager = queryMultiAdapter(
         (self.folder, request, view),
         IContentProvider,
         'plone.abovecontentbody')
     viewlet = queryMultiAdapter(
         (self.folder, request, view, viewlet_manager),
         IViewlet,
         'collective.calltoaction')
     self.assertTrue(viewlet is None)
开发者ID:collective,项目名称:collective.calltoaction,代码行数:16,代码来源:test_viewlet.py

示例11: available

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
    def available(self):
        if not (IViewView.providedBy(self.view) \
             or IFolderContentsView.providedBy(self.view)):
            return False

        context = aq_inner(self.context)

        if not IQuickUploadCapable.providedBy(context):
            return False
        elif IQuickUploadNotCapable.providedBy(context):
            return False
        elif not self.pm.checkPermission('Add portal content', context):
            return False
        elif isTemporary(context):
            return False

        upload_portal_type = self.data.upload_portal_type
        if (upload_portal_type and upload_portal_type != 'auto'
                and upload_portal_type not in [t.id for t
                        in self.context.getAllowedTypes()]):
            return False
        else:
            return True
开发者ID:Conectivo,项目名称:collective.quickupload,代码行数:25,代码来源:quickuploadportlet.py

示例12: show_viewlet

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
    def show_viewlet(self):

        # TODO => all details, even the default ones, should be defined
        # through an item detail viewlet
        man = ItemDetailViewletManager(self.context, self.request, self)
        man.update()

        if man.viewlets:
            return True

        if hasattr(self.view, 'show_facility_viewlet'):
            return self.view.show_facility_viewlet

        # Only show on default view
        if not IViewView.providedBy(self.view):
            return False

        attributes = [
            'image',
            'opening_hours',
            'description',
            'contact',
            'infrastructure',
            'terms_of_use',
            'notes',
        ]

        for a in attributes:
            if not hasattr(self.context, a):
                return False

        for a in attributes:
            if getattr(self.context, a):
                return True

        return False
开发者ID:seantis,项目名称:seantis.dir.facility,代码行数:38,代码来源:item.py

示例13: update

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
 def update(self):
     if IViewView.providedBy(self.__parent__):
         alsoProvides(self, IViewView)
开发者ID:djay,项目名称:collective.carousel,代码行数:5,代码来源:viewlets.py

示例14: _initializeData

# 需要导入模块: from plone.app.layout.globals.interfaces import IViewView [as 别名]
# 或者: from plone.app.layout.globals.interfaces.IViewView import providedBy [as 别名]
    def _initializeData(self, options=None, view=None, template=None):
        # We don't want to do this in __init__ because the view provides
        # methods which are useful outside of globals.  Also, performing
        # actions during __init__ is dangerous because instances are usually
        # created during traversal, which means authentication hasn't yet
        # happened.
        context = aq_inner(self.context)
        if options is None:
            options = {}
        if view is None:
            view = self

        show_portlets = not options.get("no_portlets", False)
        def_actions = options.get("actions", None)

        # XXX: Can't store data as attributes directly because it will
        # insert the view into the acquisition chain. Someone should
        # come up with a way to prevent this or get rid of the globals
        # view altogether

        tools = getMultiAdapter((context, self.request), name=u"plone_tools")
        portal_state = getMultiAdapter((context, self.request), name=u"plone_portal_state")
        context_state = getMultiAdapter((context, self.request), name=u"plone_context_state")

        self._data["utool"] = utool = tools.url()
        self._data["portal"] = portal = portal_state.portal()
        self._data["portal_url"] = portal_state.portal_url()
        self._data["mtool"] = mtool = tools.membership()
        self._data["atool"] = atool = tools.actions()
        self._data["putils"] = putils = getToolByName(context, "plone_utils")
        self._data["acl_users"] = getToolByName(context, "acl_users")
        self._data["wtool"] = wtool = tools.workflow()
        self._data["ifacetool"] = tools.interface()
        self._data["syntool"] = tools.syndication()
        self._data["portal_title"] = portal_state.portal_title()
        self._data["object_title"] = context_state.object_title()
        self._data["checkPermission"] = checkPermission = mtool.checkPermission
        self._data["member"] = portal_state.member()
        self._data["membersfolder"] = mtool.getMembersFolder()
        self._data["isAnon"] = portal_state.anonymous()
        self._data["actions"] = actions = def_actions or context_state.actions()
        self._data["keyed_actions"] = def_actions or context_state.keyed_actions()
        self._data["user_actions"] = actions["user"]
        self._data["workflow_actions"] = actions["workflow"]
        self._data["folder_actions"] = actions["folder"]
        self._data["global_actions"] = actions["global"]

        portal_tabs_view = getMultiAdapter((context, context.REQUEST), name="portal_tabs_view")
        self._data["portal_tabs"] = portal_tabs_view.topLevelTabs(actions=actions)

        self._data["wf_state"] = context_state.workflow_state()
        self._data["portal_properties"] = props = tools.properties()
        self._data["site_properties"] = site_props = props.site_properties
        self._data["ztu"] = ZTUtils
        self._data["isFolderish"] = context_state.is_folderish()

        self._data["sl"] = have_left_portlets = show_portlets and self.have_portlets("plone.leftcolumn", view)
        self._data["sr"] = have_right_portlets = show_portlets and self.have_portlets("plone.rightcolumn", view)
        self._data["hidecolumns"] = self.hide_columns(have_left_portlets, have_right_portlets)

        self._data["here_url"] = context_state.object_url()
        self._data["default_language"] = portal_state.default_language()
        self._data["language"] = portal_state.language()
        self._data["is_editable"] = context_state.is_editable()
        self._data["isLocked"] = context_state.is_locked()
        self._data["isRTL"] = portal_state.is_rtl()
        self._data["visible_ids"] = self.visibleIdsEnabled() or None
        self._data["current_page_url"] = context_state.current_page_url()
        self._data["normalizeString"] = putils.normalizeString
        self._data["toLocalizedTime"] = self.toLocalizedTime
        self._data["isStructuralFolder"] = context_state.is_structural_folder()
        self._data["isContextDefaultPage"] = context_state.is_default_page()

        self._data["navigation_root_url"] = portal_state.navigation_root_url()
        self._data["Iterator"] = utils.IndexIterator
        self._data["tabindex"] = utils.IndexIterator(pos=30000, mainSlot=False)
        self._data["uniqueItemIndex"] = utils.RealIndexIterator(pos=0)

        template_id = options.get("template_id", None)
        if template_id is None and template is not None:
            template_id = template.getId()
        self._data["template_id"] = template_id

        isViewTemplate = context_state.is_view_template()
        if isViewTemplate and not IViewView.providedBy(view):
            # Mark the view as being "the" view
            alsoProvides(view, IViewView)

        self._data["isViewTemplate"] = isViewTemplate
开发者ID:dtgit,项目名称:dtedu,代码行数:91,代码来源:ploneview.py


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