def get_tool(name, context=None, default=_marker):
    """Get a portal tool by name

    :param name: The name of the tool, e.g. `portal_catalog`
    :type name: string
    :param context: A portal object
    :type context: ATContentType/DexterityContentType/CatalogBrain
    :returns: Portal Tool
    """

    # Try first with the context
    if context is not None:
        try:
            context = get_object(context)
            return getToolByName(context, name)
        except (APIError, AttributeError) as e:
            # https://github.com/senaite/bika.lims/issues/396
            logger.warn("get_tool::getToolByName({}, '{}') failed: {} "
                        "-> falling back to plone.api.portal.get_tool('{}')"
                        .format(repr(context), name, repr(e), name))
            return get_tool(name, default=default)

    # Try with the plone api
    try:
        return ploneapi.portal.get_tool(name)
    except InvalidParameterError:
        if default is not _marker:
            return default
        fail("No tool named '%s' found." % name)
def get_tool ( name , context = None , default = _marker ) : if context is not None : try : context = get_object ( context ) return getToolByName ( context , name ) except ( APIError , AttributeError ) as e : logger . warn ( "get_tool::getToolByName({}, '{}') failed: {} " "-> falling back to plone.api.portal.get_tool('{}')" . format ( repr ( context ) , name , repr ( e ) , name ) ) return get_tool ( name , default = default ) try : return ploneapi . portal . get_tool ( name ) except InvalidParameterError : if default is not _marker : return default fail ( "No tool named '%s' found." % name )
Get a portal tool by name

    :param name: The name of the tool, e.g. `portal_catalog`
    :type name: string
    :param context: A portal object
    :type context: ATContentType/DexterityContentType/CatalogBrain
    :returns: Portal Tool