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)
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)
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)
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)