from gluon.html import XML def button(merchant_id="123456789012345", products=[dict(name="shoes", quantity=1, price=23.5, currency='USD', description="running shoes black")]): t = '\n' list_products = '' for k, product in enumerate(products): for key in ('name','description','quantity','price','currency'): list_products += t % dict(k=k + 1, key=key, value=product[key]) button = """
\n%(list_products)s\n\n
""" % dict(merchant_id=merchant_id, list_products=list_products) return XML(button)