Lino Website

Documentation · Modules · adamo · Examples

pizzeria2.py

This example shows how to extend the basic pizzeria with an additional Services table.

Source code:

from lino.apps.pizzeria.pizzeria import Order
from lino.apps.pizzeria.services import MyPizzeria, populate

app = MyPizzeria() # label="Luc's Pizza Service")

dbc = app.createContext()
    
populate(dbc)

orders = dbc.query(Order)

o = orders.peek(3)

print "Order #:", o.id
print "Date:", o.date
print "Customer:", o.customer.name
print "-" * 40
for line in o.lines():
    print "%-20s %3d %5d" % (line.product.name,
                             line.qty,
                             line.product.price*line.qty)
print "-" * 40
print "Total: ", o.totalPrice

del app, dbc, o, line

Output:

Order #: 3
Date: 2004-03-18
Customer: Bernard
----------------------------------------
Pizza Margerita        1     6
bring home             1     1
----------------------------------------
Total:  7

See also: lino:src/lino/apps/pizzeria/services.py

Copyright 2001-2007 Luc Saffre.
http://lino.saffre-rumma.ee
Generated 2007-06-07 16:23:39