コード例 #1
0
ファイル: price_cache.py プロジェクト: kafura0/OranKids
def cache_many_price_info(context, item, quantity, prices_infos,
                          **context_args):
    """
    Cache a list of PriceInfo

    :param object|WSGIRequest context: the context should contain at least a shop and a customer property
    :param object item
    :param float|Decimal quantity
    :param iterable[PriceInfo] prices_infos
    """
    # check whether the prices are iterable
    try:
        iter(prices_infos)
    except TypeError:
        return

    # all items must be PriceInfo
    if not all(isinstance(item, PriceInfo) for item in prices_infos):
        return

    key = context_cache.get_cache_key_for_context(
        many=True,
        **_get_price_info_cache_key_params(context, item, quantity,
                                           **context_args))
    context_cache.set_cached_value(key, prices_infos)
コード例 #2
0
ファイル: price_cache.py プロジェクト: kafura0/OranKids
def cache_price_info(context, item, quantity, price_info, **context_args):
    """
    Cache a PriceInfo

    :param context object|WSGIRequest: the context should contain at least a shop and a customer property
    :param item any
    :param quantity float|Decimal
    :param price_info PriceInfo
    """
    # we can just cache PriceInfo instances
    if isinstance(price_info, PriceInfo):
        key = context_cache.get_cache_key_for_context(
            **_get_price_info_cache_key_params(context, item, quantity, **
                                               context_args))
        context_cache.set_cached_value(key, price_info)
コード例 #3
0
ファイル: price_cache.py プロジェクト: ruqaiya/shuup
def cache_price_info(context, item, quantity, price_info, **context_args):
    """
    Cache a PriceInfo

    :param context object|WSGIRequest: the context should contain at least a shop and a customer property
    :param item any
    :param quantity float|Decimal
    :param price_info PriceInfo
    """
    # we can just cache PriceInfo instances
    if isinstance(price_info, PriceInfo):
        key = context_cache.get_cache_key_for_context(
            **_get_price_info_cache_key_params(context, item, quantity, **context_args)
        )
        context_cache.set_cached_value(key, price_info)
コード例 #4
0
ファイル: price_cache.py プロジェクト: ruqaiya/shuup
def cache_many_price_info(context, item, quantity, prices_infos, **context_args):
    """
    Cache a list of PriceInfo

    :param object|WSGIRequest context: the context should contain at least a shop and a customer property
    :param object item
    :param float|Decimal quantity
    :param iterable[PriceInfo] prices_infos
    """
    # check whether the prices are iterable
    try:
        iter(prices_infos)
    except TypeError:
        return

    # all items must be PriceInfo
    if not all(isinstance(item, PriceInfo) for item in prices_infos):
        return

    key = context_cache.get_cache_key_for_context(
        many=True,
        **_get_price_info_cache_key_params(context, item, quantity, **context_args)
    )
    context_cache.set_cached_value(key, prices_infos)