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


Python IReadContainer.providedBy方法代码示例

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


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

示例1: __new__

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
 def __new__(cls, context, request, view, manager):
     chain = _get_context_chain(context)
     chain.pop() # bungeni_app
     top_section = chain.pop()
     
     if not chain:
         return
     
     # we require the tree to begin with a container object
     if not IReadContainer.providedBy(chain[-1]):
         return
     
     # remove any views from navigation tree
     if not(IAlchemistContent.providedBy(chain[0]) or 
             IAlchemistContainer.providedBy(chain[0]) or
             ISection.providedBy(chain[0])
         ):
         chain.pop(0)
     
     subcontext = chain[-1]
     if (len(chain) > 1 or
             IReadContainer.providedBy(subcontext) and 
             not IAlchemistContainer.providedBy(subcontext) and 
             len(subcontext)
         ):
         inst = object.__new__(cls, context, request, view, manager)
         inst.chain = chain
         inst.top_section_url = url.absoluteURL(top_section, request)
         inst.id_prefix = "nav"
         return inst
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:32,代码来源:navigation.py

示例2: add_container_menu_items

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
 def add_container_menu_items(self, context, container):
     request = self.request
     
     _url = url.absoluteURL(container, request)
     
     if IReadContainer.providedBy(container):
         #XXX should be the same in all containers ?
         container=proxy.removeSecurityProxy(container)
         for name, item in container.items():
             if context is None:
                 selected = False
             else:
                 selected = url.same_path_names(context.__name__, name)
             item = proxy.removeSecurityProxy(item)
             if IDCDescriptiveProperties.providedBy(item):
                 title = item.title
             else:
                 props = IDCDescriptiveProperties(item)
                 title = props.title
             # only items with valid title
             if title is not None:
                 self.items.append(url.get_menu_item_descriptor(
                         title, selected, _url, name))
     default_view_name = queryDefaultViewName(container, self.request)
     default_view = component.queryMultiAdapter(
         (container, self.request), name=default_view_name)
     if hasattr(default_view, "title") and default_view.title is not None:
         self.items.insert(0, url.get_menu_item_descriptor(
                 default_view.title, 
                 sameProxiedObjects(container, self.context), 
                 _url))
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:33,代码来源:navigation.py

示例3: update

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
 def update(self):
     request = self.request
     context = self.context
     chain = _get_context_chain(context)
     length = len(chain)
     self.items = []
     if length < 2:
         # there must be at least: [top-level section, application]
         return # container is None
     else:
         # the penultimate context is the top-level container
         container = chain[-2]
         assert container.__name__ is not None
         if not IReadContainer.providedBy(container):
             return # container has no readable content
     assert container is not None
     
     # add container items
     if length > 2:
         context = chain[-3]
     else:
         context = None
     self.add_container_menu_items(context, container)
     # add any menu items from zcml
     self.add_zcml_menu_items(container)
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:27,代码来源:navigation.py

示例4: publishTraverse

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
    def publishTraverse(self, request, name):
        subob = self.traverse(name)
        if subob is not None:
            return safely_locate_maybe(subob, self.context, name)

        traversable_dict = traversable.bind().get(self.context)
        if traversable_dict:
            if name in traversable_dict:
                subob = getattr(self.context, traversable_dict[name])
                if callable(subob):
                    subob = subob()
                return safely_locate_maybe(subob, self.context, name)

        # XXX Special logic here to deal with containers.  It would be
        # good if we wouldn't have to do this here. One solution is to
        # rip this out and make you subclass ContainerTraverser if you
        # wanted to override the traversal behaviour of containers.
        if IReadContainer.providedBy(self.context):
            item = self.context.get(name)
            if item is not None:
                return item

        view = component.queryMultiAdapter((self.context, request), name=name)
        if view is not None:
            return view

        raise NotFound(self.context, name, request)
开发者ID:jean,项目名称:grokcore.traverser,代码行数:29,代码来源:components.py

示例5: subItems

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
 def subItems(self):
     """Collect all tree items for the given context."""
     items = []
     keys = []
     append = items.append
     if IReadContainer.providedBy(self.context):
         try:
             keys = list(self.context.keys())
         except(Unauthorized, Forbidden):
             return items
     else:
         return items
     counter = 1
     for name in keys:
         # Only include items we can traverse to
         subItem = api.traverse(self.context, name, None)
         if subItem is not None:
             append((api.getName(subItem), subItem,
                 self._hasSubItems(subItem)))
         counter += 1
         if counter == self.maxItems:
             # add context which should support a item listing view with 
             # batch
             lenght = len(keys) - self.maxItems
             default = '[%s more items...]' % lenght
             name = zope.i18n.translate(
                 _('[${lenght} more items...]', mapping={'lenght':lenght}),
                 context=self.request, default=default)
             append((name, self.context, False))
             break
     return items
开发者ID:zopefoundation,项目名称:z3c.jsontree,代码行数:33,代码来源:subitem.py

示例6: getLengthOf

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
 def getLengthOf(self, item):
     res = -1
     if IReadContainer.providedBy(item):
         try:
             res = len(item)
         except (Unauthorized, Forbidden):
             pass
     return res
开发者ID:grodniewicz,项目名称:oship,代码行数:10,代码来源:xmlobject.py

示例7: singleBranchTree

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
 def singleBranchTree(self, root=''):
     parent = getParent(self.context)
     while parent is not None:
             if IReadContainer.providedBy(parent):
                 view = queryMultiAdapter(
                     (parent, self.request), name='singleBranchTree.xml')
                 return view()
             else:
                 parent = getParent(parent)
开发者ID:grodniewicz,项目名称:oship,代码行数:11,代码来源:xmlobject.py

示例8: __new__

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
    def __new__(cls, context, request, view, manager):
        # we have both primary and secondary navigation, so we won't
        # show the navigation tree unless we're at a depth > 2
        chain = _get_context_chain(context)[:-2]
        if not chain:
            return

        # we require the tree to begin with a container object
        if not IReadContainer.providedBy(chain[-1]):
            return

        subcontext = chain[-1]
        if (len(chain) > 1 or
            IReadContainer.providedBy(subcontext) and not
            IAlchemistContainer.providedBy(subcontext) and len(subcontext)):
            inst = object.__new__(cls, context, request, view, manager)
            inst.chain = chain
            return inst
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:20,代码来源:navigation.py

示例9: _hasSubItems

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
 def _hasSubItems(self, item):
     """This method allows us to decide if a sub item has items from the 
     point of view of the context."""
     res = False
     if IReadContainer.providedBy(item):
         try:
             if len(item) > 0:
                 res = True
         except(Unauthorized, Forbidden):
             pass
     return res
开发者ID:zopefoundation,项目名称:z3c.jsontree,代码行数:13,代码来源:subitem.py

示例10: getObjectURL

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
def getObjectURL(ob, req):
    """Return the URL for the object `ob`.

    If the object is a container and the url doesn't end in slash '/' then
    append a slash to the url.
    """
    url = zope.component.getMultiAdapter((ob, req), IAbsoluteURL)()
    if IReadContainer.providedBy(ob) and url[-1] != "/":
        url += "/"

    return url
开发者ID:mkerrin,项目名称:z3c.dav,代码行数:13,代码来源:utils.py

示例11: add_container_menu_items

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
    def add_container_menu_items(self, context, container):
        request = self.request
        # add a menu item for each user workspace, if we are in an
        # IWorkspaceSectionLayer
        # !+ if user is logged in or if request.layer_data
        if interfaces.IWorkspaceSectionLayer.providedBy(request):
            try:
                workspaces = IAnnotations(request)["layer_data"].get(
                    "workspaces")
            except:
                workspaces = []
            log.info("%s got user workspaces: %s" % (self, workspaces))
            base_url_path = "/workspace"
            for workspace in workspaces:
                log.info("appending menu item for user workspace: %s" %
                         str(workspace))
                self.items.append(
                    url.get_menu_item_descriptor(
                        workspace.full_name,
                        pos_action_in_url(
                            "/workspace/obj-%s" % workspace.group_id,
                            request.getURL()), base_url_path,
                        "obj-%s" % workspace.group_id))

        _url = url.absoluteURL(container, request)

        if IReadContainer.providedBy(container):
            #XXX should be the same in all containers ?
            container = proxy.removeSecurityProxy(container)
            for name, item in container.items():
                if context is None:
                    selected = False
                else:
                    selected = url.same_path_names(context.__name__, name)
                item = proxy.removeSecurityProxy(item)
                if IDCDescriptiveProperties.providedBy(item):
                    title = item.title
                else:
                    props = IDCDescriptiveProperties(item)
                    title = props.title
                # only items with valid title
                if title is not None:
                    self.items.append(
                        url.get_menu_item_descriptor(title, selected, _url,
                                                     name))
        default_view_name = queryDefaultViewName(container, self.request)
        default_view = component.queryMultiAdapter((container, self.request),
                                                   name=default_view_name)
        if hasattr(default_view, "title") and default_view.title is not None:
            self.items.insert(
                0,
                url.get_menu_item_descriptor(
                    default_view.title,
                    sameProxiedObjects(container, self.context), _url))
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:56,代码来源:navigation.py

示例12: _search_helper

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
def _search_helper(id, obj, container, id_filters, object_filters, result):
    # check id filters if we get a match then return immediately
    for id_filter in id_filters:
        if id_filter.matches(id):
            result.append(obj)
            return

    # now check all object filters
    for object_filter in object_filters:
        if object_filter.matches(obj):
            result.append(obj)
            return

    # do we need to check sub containers?
    if not IReadContainer.providedBy(obj):
        return

    for key, value in obj.items():
        _search_helper(key, value, obj, id_filters, object_filters, result)
开发者ID:jean,项目名称:z3c.contents,代码行数:21,代码来源:value.py

示例13: matches

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
 def matches(self, object):
     if IReadContainer.providedBy(object):
         return len(object) == self._count
     else:
         return False
开发者ID:jean,项目名称:zope.container,代码行数:7,代码来源:test_find.py

示例14: is_container

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
 def is_container(self):
     # I recommend reimplement this and return IS_CONTAINER
     # or empty string directly
     return IReadContainer.providedBy(self.context) or u''
开发者ID:fudong1127,项目名称:ice.control,代码行数:6,代码来源:xmlbase.py

示例15: expand

# 需要导入模块: from zope.container.interfaces import IReadContainer [as 别名]
# 或者: from zope.container.interfaces.IReadContainer import providedBy [as 别名]
    def expand(self, chain, include_siblings=True):
        if len(chain) == 0:
            return ()

        context = chain.pop()
        items = []

        if IApplication.providedBy(context):
            items.extend(self.expand(chain))

        elif IAlchemistContent.providedBy(context):
            _url = url.absoluteURL(context, self.request)
            if IDCDescriptiveProperties.providedBy(context):
                title = context.title
            else:
                props = IDCDescriptiveProperties(context, None)
                if props is not None:
                    title = props.title
                else:
                    title = context.short_name

            selected = len(chain) == 0
            
            if chain:
                nodes = self.expand(chain)
            else:
                kls = context.__class__
                containers = [
                    (key, getattr(context, key))
                    for key, value in kls.__dict__.items()
                    if isinstance(value, ManagedContainerDescriptor)]
                nodes = []
                self.expand_containers(nodes, containers, _url, chain, None)

            items.append(
                {'title': title,
                 'url': _url,
                 'current': True,
                 'selected': selected,
                 'kind': 'content',
                 'nodes': nodes,
                 })

        elif IAlchemistContainer.providedBy(context):
            # loop through all managed containers of the parent
            # object, and include the present container as the
            # 'current' node.
            parent = context.__parent__
            assert parent is not None
            _url = url.absoluteURL(parent, self.request)

            # append managed containers as child nodes
            kls = type(proxy.removeSecurityProxy(parent))

            if include_siblings is True:
                if IApplication.providedBy(parent):
                    containers = [
                        (name, parent[name])
                        for name in 
                            location.model_to_container_name_mapping.values()
                        if name in parent
                    ]
                elif IReadContainer.providedBy(parent):
                    containers = list(parent.items())
                else:
                    containers = [
                        (key, getattr(parent, key))
                        for key, value in kls.__dict__.items()
                        if isinstance(value, ManagedContainerDescriptor)]
            else:
                containers = [(context.__name__, context)]
                
            self.expand_containers(items, containers, _url, chain, context)

        elif ILocation.providedBy(context):
            _url = url.absoluteURL(context, self.request)
            #props = IDCDescriptiveProperties.providedBy(context) and \
            #    context or IDCDescriptiveProperties(context)
            if IDCDescriptiveProperties.providedBy(context):
                props = IDCDescriptiveProperties(context)
            else:
                props = context
            props = proxy.removeSecurityProxy(props)

            selected = len(chain) == 0
            if selected and IReadContainer.providedBy(context):
                nodes = []
                try:
                    self.expand_containers(
                        nodes, context.items(), _url, chain, context)
                except:
                    pass
            else:
                nodes = self.expand(chain)
            i_id = getattr(props, 'id','N/A')
            items.append(
                {'title': getattr(props, 'title', i_id),
                 'url': _url,
                 'current': True,
                 'selected': selected,
#.........这里部分代码省略.........
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:103,代码来源:navigation.py


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