Lino Website

Documentation · Modules · adamo · Examples

sprl2.py

This example shows a list of all tables of sprl, together with their fields and details.

Source code:

from lino.apps.ledger.ledger_tables import LedgerSchema
from lino.reports import Report
from lino.adamo.rowattrs import Field, Pointer, Detail

class SchemaOverview(Report):
    def __init__(self,schema):
        self.schema=schema
        Report.__init__(self)
        
    def getIterator(self):
        return self.schema.getTableList()
        
    def setupReport(self):

        self.addVurtColumn(
            label="TableName",
            meth=lambda row: row.item.getTableName(),
            width=15)
        self.addVurtColumn(
            label="Fields",
            meth=lambda row:\
            ", ".join([fld.name for fld in row.item.getFields()
                       if isinstance(fld,Field) \
                       and not isinstance(fld,Pointer)]),
            width=20)
        self.addVurtColumn(
            label="Pointers",
            meth=lambda row:\
            ", ".join([fld.name for fld in row.item.getFields()
                       if isinstance(fld,Pointer)]),
            width=15)
        self.addVurtColumn(
            label="Details",
            meth=lambda row:\
            ", ".join([fld.name for fld in row.item.getFields()
                       if isinstance(fld,Detail)]),
            width=25)


sch=LedgerSchema()
rpt=SchemaOverview(sch)
rpt.show()

Output:

TableName      |Fields              |Pointers       |Details                  
---------------+--------------------+---------------+-------------------------
Currencies     |id, name            |               |                         
Products       |id, name, price     |               |                         
Journals       |id, name, tableName |               |                         
BankStatements |seq, date, closed,  |jnl            |                         
               |remark, balance1,   |               |                         
               |balance2            |               |                         
MiscOperations |seq, date, closed,  |jnl            |                         
               |remark              |               |                         
Invoices       |seq, date, closed,  |jnl, contact   |lines                    
               |remark, zziel,      |               |                         
               |amount, inverted    |               |                         
InvoiceLines   |line, amount,       |invoice,       |                         
               |remark, unitPrice,  |product        |                         
               |qty                 |               |                         
BalanceItems   |name, id, attrib,   |               |                         
               |dc, type, doc       |               |                         
CashFlowItems  |name, id, attrib,   |               |                         
               |dc, type, doc       |               |                         
ProfitAndLossIt|name, id, attrib,   |               |                         
ems            |dc, type, doc       |               |                         
Accounts       |name, pcmn, id      |parent,        |                         
               |                    |balance,       |                         
               |                    |profit, cash   |                         
Bookings       |date, amount, dc,   |account,       |                         
               |label, id           |invoice,       |                         
               |                    |contact        |                         
Languages      |id, name            |               |                         
Nations        |id, name, area,     |               |cities,                  
               |population, curr,   |               |contacts_by_nation       
               |isocode             |               |                         
Cities         |id, name, zipCode,  |nation         |                         
               |inhabitants         |               |                         
Organisations  |id, name, name2,    |               |                         
               |logo, memo          |               |                         
Persons        |id, name, firstName,|               |contacts                 
               |sex, birthDate,     |               |                         
               |memo, title         |               |                         
Functions      |id, name            |               |                         
Contacts       |id, name, email,    |org, person,   |                         
               |phone, gsm, fax,    |function, lang,|                         
               |website, zip,       |nation, city,  |                         
               |street, house, box  |currency       |                         

Refering articles:

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