def _block(brain_or_object):

        if req.get("only_children"):
            return get_children(brain_or_object)

        # extract the data using the default info adapter
        info = IInfo(brain_or_object)()

        # might be None for mixed type catalog results, e.g. in the search route
        scoped_endpoint = endpoint
        if scoped_endpoint is None:
            scoped_endpoint = get_endpoint(get_portal_type(brain_or_object))

        info.update(get_url_info(brain_or_object, scoped_endpoint))

        # switch to wake up the object and complete the informations with the
        # data of the content adapter
        if complete:
            obj = get_object(brain_or_object)
            info.update(IInfo(obj)())
            info.update(get_parent_info(obj))
            if req.get_children():
                info.update(get_children(obj))

        return info
Exemple #2
0
    def _block(brain_or_object):

        if req.get("only_children"):
            return get_children(brain_or_object)

        # extract the data using the default info adapter
        info = IInfo(brain_or_object)()

        # might be None for mixed type catalog results, e.g. in the search route
        scoped_endpoint = endpoint
        if scoped_endpoint is None:
            scoped_endpoint = get_endpoint(get_portal_type(brain_or_object))

        info.update(get_url_info(brain_or_object, scoped_endpoint))

        # switch to wake up the object and complete the informations with the
        # data of the content adapter
        if complete:
            obj = get_object(brain_or_object)
            info.update(IInfo(obj)())
            info.update(get_parent_info(obj))
            if req.get_children():
                info.update(get_children(obj))

        return info
Exemple #3
0
def make_items_for(brains_or_objects, endpoint=None, complete=False):
    """Generate API compatible data items for the given list of brains/objects

    :param brains_or_objects: List of objects or brains
    :type brains_or_objects: list/Products.ZCatalog.Lazy.LazyMap
    :param endpoint: The named URL endpoint for the root of the items
    :type endpoint: str/unicode
    :param complete: Flag to wake up the object and fetch all data
    :type complete: bool
    :returns: A list of extracted data items
    :rtype: list
    """

    # check if the user wants to include children
    include_children = req.get_children(False)

    def extract_data(brain_or_object):
        info = get_info(brain_or_object, endpoint=endpoint, complete=complete)
        if include_children and is_folderish(brain_or_object):
            info.update(get_children_info(brain_or_object, complete=complete))
        return info

    return map(extract_data, brains_or_objects)
Exemple #4
0
def make_items_for(brains_or_objects, endpoint=None, complete=False):
    """Generate API compatible data items for the given list of brains/objects

    :param brains_or_objects: List of objects or brains
    :type brains_or_objects: list/Products.ZCatalog.Lazy.LazyMap
    :param endpoint: The named URL endpoint for the root of the items
    :type endpoint: str/unicode
    :param complete: Flag to wake up the object and fetch all data
    :type complete: bool
    :returns: A list of extracted data items
    :rtype: list
    """

    # check if the user wants to include children
    include_children = req.get_children(False)

    def extract_data(brain_or_object):
        info = get_info(brain_or_object, endpoint=endpoint, complete=complete)
        if include_children and is_folderish(brain_or_object):
            info.update(get_children_info(brain_or_object, complete=complete))
        return info

    return map(extract_data, brains_or_objects)