Class s.r.b.t.BaseReportTemplate(BaseDocTemplate):

Part of stoqlib.reporting.base.template View In Hierarchy

Known subclasses: stoqlib.reporting.base.printing.ReportTemplate

Base class representing the document itself. Here is implemented all the methods to reporting elements insertion, like signatures, tables, paragraphs and so on.
Method __init__ The parameters are:
Method save Build and saves the report. Internal use (you don't need to call
Method build Build the report - initialize all the pages and start drawing its
Method setup_page_templates Report initialization. Here we have to initialize report control
Method add Adds a flowable to report.
Method start_group Starts flowables groupping.
Method end_group Finish flowables groupping
Method get_usable_width Returns the horizontal space available for drawing.
Method get_usable_height Returns the vertical space available for drawing.
Method set_page_number Sets the current page.
Method get_page_number Returns the current page number
Method add_page_break Adds a simple page break
Method add_document_break This method adds a document break, starting a new document.
Method add_blank_space Adds a blank space on the current report position. Through
Method add_signatures Adds a signature flowable.
Method add_preformatted_text Adds a given given text to the document, using a given
Method add_paragraph Adds a paragraph to the document, using a given style.
Method add_line Insert a simple line on the report.
Method add_title Adds a title. The title flowable is composed of a text inside two
Method add_report_table Inserts a report table.
Method add_column_table Adds a column table.
Method add_object_table Insert an object table. Its parameters are:
Method add_grouping_table TODO
Method add_data_table Insert a data table on the report.
Method paint_page_canvas This method is called by Reportlab on each time that a page starts
Method draw_header Hook called on report header drawing time.
Method draw_footer Hook called on report footer drawing time.
def __init__(self, filename, report_name, pagesize=pagesizes.A4, landscape=0, do_header=0, do_footer=0, **kwargs):
The parameters are:
ParametersfilenameThe filename where the report will saved to (since the package only works with PDF files right now, it is desirable a .pdf extension right after the name) (type: str )
report_nameThe name used to fill the report footer. (type: str )
pagesizeThe pagesize, no secrets here. Defaults to A4. (type: One of the constants available on reportlab.lib.pagesizes module. )
landscapeDefine if the report must be drawed in the landscape format. Defaults to False. (type: bool )
do_footerMust the report footer be drawed? Defaults to False (type: bool )
def save(self):
Build and saves the report. Internal use (you don't need to call this method in most of the cases).
def build(self):
Build the report - initialize all the pages and start drawing its elements. Internal use (you don't need to call this method in most of the cases).
def setup_page_templates(self):
Report initialization. Here we have to initialize report control attributes.
def add(self, flowable):
Adds a flowable to report.
def start_group(self):
Starts flowables groupping.
def end_group(self, min_flowables=0):
Finish flowables groupping
def get_usable_width(self):
Returns the horizontal space available for drawing.
def get_usable_height(self):
Returns the vertical space available for drawing.
def set_page_number(self, number):
Sets the current page.
ParametersnumberThe new page number. (type: int )
def get_page_number(self):
Returns the current page number
def add_page_break(self):
Adds a simple page break
def add_document_break(self):
This method adds a document break, starting a new document.
def add_blank_space(self, height=10, width=-1):
Adds a blank space on the current report position. Through height e width parameters is possible defines the space type that we want, i.e, a vertical space (in this case, we pass width=-1 and height=X, where represents the space desired) or a horizontal space (height=-1, width=X). The default is a vertical space.
ParametersheightHow much vertical space? (type: int/float )
widthHow much horizontal space? (type: int/float )
def add_signatures(self, labels, *args, **kwargs):
Adds a signature flowable.
ParameterslabelsA list of signatures (text). For list greater than 1 the signatures will be put side by side on the report. (type: list )
alignSet the signatures group alignment. (type: One of LEFT, CENTER or RIGHT constants defined in the stoqlib reporting flowables module. )
line_widthThe signature line width. (type: int/float )
heightHow much space before the signature? (type: int/float )
text_alignThe signature text alignment. (type: One of LEFT, CENTER or RIGHT constants defined in the stoqlib reporting flowables module. )
style_dataAn optional paragraph style for the signature text. (type: One of paragraph styles defined in the default_style method. )
def add_preformatted_text(self, text, *args, style='Raw', **kwargs):
Adds a given given text to the document, using a given style. ('Raw' by default)
ParameterstextThe text. (type: str )
styleOne of the paragraph style names defined in the default_style module. Defaults to 'Raw' style. (type: str )
def add_paragraph(self, text, style='Normal', **kwargs):
Adds a paragraph to the document, using a given style. ('Normal by default')
ParameterstextThe paragraph text. (type: str )
styleOne of the paragraph style names defined in the default_style module (type: str )
def add_line(self, *args, **kwargs):
Insert a simple line on the report.
def add_title(self, title, notes=, space_before=SPACING, style='Title', note_style='Title-Note'):
Adds a title. The title flowable is composed of a text inside two separators. Title notes also can be inserted, in this case an extra text will be put below the title.
ParameterstitleThe title text. (type: str )
noteThe title notes. (type: list )
space_beforeHow much space (in mm) must be given before the title can be drawed? Defaults to the SPACING constant defined on default_style module (type: float )
styleOne of the style names defined on the default_style module. (type: str )
note_styleOne of the style names defined on the default_style module (type: str )
def add_report_table(self, data, *args, header=None, style=TABLE_STYLE, margins=DEFAULT_MARGIN, align=flowables.CENTER, extra_row=None, table_line=TABLE_LINE, highlight=tables.HIGHLIGHT_ODD, **kwargs):
Inserts a report table.
ParametersdataA list of lists, where each nested list represents a row (naturally, each column of this nested list is a table column). (type: list )
headerA list of string representing the header of each column. (type: list )
styleThe table style. @type style TableStyle
marginsHow much space before and after the table? @type margins float/int
alignThe table alignment. One of LEFT, RIGHT, CENTER constants defined on stoqlib reporting flowables module. (type: One of LEFT, RIGHT or CENTER )
extra_rowAn list of strings to be inserted right after the table. (type: list )
table_lineDefine the type of the line that is inserted between the table rows. (type: One of TABLE_LINE or TABLE_LINE_BLANK constants. )
highlightSets the table highlight type. (type: One of HIGHLIGHT_ODD, HIGHLIGHT_NEVER or HIGHLIGHT_ODD constants defined on stoqlib reporting tables module. )
def add_column_table(self, data, columns, *args, style=TABLE_STYLE, margins=DEFAULT_MARGIN, align=flowables.CENTER, extra_row=None, table_line=TABLE_LINE, do_header=True, highlight=tables.HIGHLIGHT_ODD, **kwargs):
Adds a column table.
ParametersdataA list of lists, where each nested list represents a row (naturally, each column of this nested list is a table column). (type: list )
columnsA list of TableColumn instances representing the table columns (type: list )
styleThe table style. @type style TableStyle
marginsHow much space before and after the table? (type: float/int )
alignThe table alignment. One of LEFT, RIGHT, CENTER constants defined on stoqlib reporting flowables module. (type: One of LEFT, RIGHT or CENTER )
extra_rowAn list of strings to be inserted right after the table. (type: list )
table_lineDefine the type of the line that is inserted between the table rows. (type: One of TABLE_LINE or TABLE_LINE_BLANK constants. )
do_headerMust the table header be drawed? Defaults to True (type: bool )
highlightSets the table highlight type. (type: One of HIGHLIGHT_ODD, HIGHLIGHT_NEVER or HIGHLIGHT_ODD constants defined on stoqlib reporting tables module. )
def add_object_table(self, objs, cols, *args, expand=False, width=0, style=TABLE_STYLE, margins=DEFAULT_MARGIN, extra_row=None, align=flowables.CENTER, table_line=TABLE_LINE, highlight=tables.HIGHLIGHT_ODD, summary_row=None, **kwargs):
Insert an object table. Its parameters are:
ParametersobjsA instance list, where each instance is a table row. (type: list. )
colsA list of ObjectTableColumn, representing the table columns. (type: list )
expandMust be the columns expanded? Defaults to False. (type: bool )
widthThe table width. (type: int )
styleThe table style. (type: TableStyle )
marginsHow much space before and after the table? (type: int/float )
extra_rowAn list of strings to be inserted right after the table. This data is included on the report as a normal data table after this object table. (type: list )
alignThe table alignment. (type: One of LEFT, RIGHT or CENTER )
table_lineDefine the type of the line that is inserted between the table rows. (type: One of TABLE_LINE or TABLE_LINE_BLANK constants. )
highlightSets the table highlight type.
highight (type: One of HIGHLIGHT_ODD, HIGHLIGHT_NEVER or HIGHLIGHT_ODD constants defined on stoqlib reporting tables module. )
def add_grouping_table(self, objs, column_groups, column_widths, *args, header=None, style=TABLE_STYLE, margins=DEFAULT_MARGIN, align=flowables.CENTER, extra_row=None, **kwargs):
TODO
def add_data_table(self, data, *args, style=TABLE_STYLE, margins=DEFAULT_MARGIN, align=flowables.LEFT, **kwargs):
Insert a data table on the report.
ParametersdataThe data list. It is composed of list of a lists, where each nested list represents a row. Note that the nested lists must have all the same length. (type: list )
styleThe table style. (type: TableStyle )
marginsHow much space before and after the table? (type: float/int )
alignThe table alignment. One of LEFT, RIGHT, CENTER constants defined on stoqlib reporting flowables module. (type: One of LEFT, RIGHT or CENTER )
def paint_page_canvas(self, canvas, doc):
This method is called by Reportlab on each time that a page starts be drawed.
def draw_header(self, canvas):
Hook called on report header drawing time.
def draw_footer(self, canvas):
Hook called on report footer drawing time.
API Documentation for Stoqlib, generated by pydoctor at 2009-07-14 16:00:32.