def set_global_context(self):
        # Get the valid prices
        self.products = Product.get_all_products()
        self.pricelist = self.campaign.get_product_prices()


        # Translate to json.
        self.catalog_json = dumps({
            'products': {code: p.as_jsonable() for code, p in self.products.iteritems()},
            'prices': {code: pp.as_jsonable() for code, pp in self.pricelist.iteritems()}
        })
        #self.products_json = dumps({code: p.as_jsonable() for code, p in self.products.iteritems()})
        self.pricelist_json = dumps({code: pp.as_jsonable() for code, pp in self.pricelist.iteritems()})
示例#2
0
    def set_global_context(self):
        # Get the valid prices
        self.products = Product.get_all_products()
        self.pricelist = self.campaign.get_product_prices()

        # Translate to json.
        self.catalog_json = dumps({
            'products':
            {code: p.as_jsonable()
             for code, p in self.products.iteritems()},
            'prices': {
                code: pp.as_jsonable()
                for code, pp in self.pricelist.iteritems()
            }
        })
        #self.products_json = dumps({code: p.as_jsonable() for code, p in self.products.iteritems()})
        self.pricelist_json = dumps({
            code: pp.as_jsonable()
            for code, pp in self.pricelist.iteritems()
        })
示例#3
0
 def as_json(self):
     from handy.jsonstuff import dumps
     return dumps(self.as_jsonable())