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


Python Category.list方法代码示例

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


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

示例1: service_category_list

# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import list [as 别名]
    def service_category_list(self):
        """
        Returns list of categories with localized names

        :return list category_list: List of dict with category

        **Example**::

             {"category_list": [
                {"category_id": "net", "localized_name": {"ru": "Сеть", "en": "Network"}},
                {"category_id": "storage", "localized_name": {"ru": "Хранение данных", "en": "Storage"}},
                {"category_id": "vm", "localized_name": {"ru": "Виртуальные машины", "en": "Virtual machine"}},
                {"category_id": "custom", "localized_name": {"ru": "Дополнительные", "en": "Custom"}}]}

        """
        return {"category_list": display(Category.list().values())}
开发者ID:deti,项目名称:boss,代码行数:18,代码来源:service.py

示例2: List

# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import list [as 别名]
import conf
import errors
from model import display, autocommit
from api import get, post, delete, AdminApi, put
from api.check_params import check_params
from api.validator import IntRange, String, TokenId, List, Choose, LocalizedName, ModelId, Visibility, Integer
from api.admin.role import TokenAdmin, TokenAccount, TokenManager
from model import Category, Service, Measure
from os_interfaces.openstack_wrapper import openstack
from novaclient.exceptions import NotFound

CategoryList = List(Choose(list(Category.list().keys())))
MeasureTime = Choose({measure.measure_id: measure for measure in Measure.list(Measure.TIME)})
ServiceIdExpand = ModelId(Service, errors.ServiceNotFound)
ServiceId = ModelId(Service, errors.ServiceNotFound, expand=False)


class ServiceApi(AdminApi):
    @get("category/")
    @check_params(
        token=TokenId,
    )
    def service_category_list(self):
        """
        Returns list of categories with localized names

        :return list category_list: List of dict with category

        **Example**::

             {"category_list": [
开发者ID:deti,项目名称:boss,代码行数:33,代码来源:service.py


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