Last page update: November 23, 2011
Classes:
Complete reference:
With the term webpages variables we mean that there are some defined variables that you can use to customize the class to which they belong (in this case, the BagToHtml class).
Note
the unit of measurement of all the numerical variables are in millimeters (e.g: print_width = 200 means 200 millimeters)
Note
the three levels in which is divided the print zone are:
Most of the following webpage variables are related to these three print zones; please check the Layout print regions section for more information about them
The webpage variables are:
- copies_per_page
- copy_extra_height
- css_requires
- currencyFormat
- doc_header_height
- doc_footer_height
- encoding
- grid_header_height
- grid_footer_height
- grid_col_headers
- grid_col_widths
- grid_row_height
- page_debug
- page_footer_height
- page_header_height
- page_height
- page_width
- page_leftbar_width
- page_rightbar_width
- page_margin_bottom
- page_margin_left
- page_margin_right
- page_margin_top
- print_button
- row_mode
- rows_path
- starting_page_number
- templates
TODO. Default value is 1
TODO. Default value is 0
Set the css files to import. Default value is '' (empty string)
Example:
css_requires = 'my_style'This line implies that you have created a CSS file called my_style.css
Set the format of the numerical columns of the print. Default value is u'#,###.00'
Set the height of the doc header in millimeters. Default value is 0.
Note
you can call the docHeader() method only if you give a different dimension respect to 0 to this attribute
Set the encoding of your data. Default value is 'utf-8'
Set the height of the grid header in millimeters. Default value is 0
String. Set the header names of the print columns. Default value is None
List. Set the width of the grid columns in millimeters. Default value is [0, 0, 0]
Note
Every column you set equal to 0 takes the remaining place divided equally
Example:
grid_col_widths = [0,0,0]in this example we have 3 columns that get the current grid width divided equally in 3
Example:
grid_col_widths = [17,12,0,0,20,15,15,20]in this example we have 8 columns; the first one measures 17 mm, the second one 12 mm and so on. The total millimeters specified are 99 (17+12+20+15+15+20), so if we suppose that the total width of the grid is 149 millimeters, then the remaining space (that is: 149 - 99 = 50 millimeters) will be taken from the third and the fourth columns divided equally (both the third and the fourth columns have a width of 50:2 = 25 millimeters)
Set the height of the grid rows in millimeters. Default value is 5
Example:
grid_row_height = 5.3
boolean. TODO Default value is False
Set the page header height in millimeters. Default value is 0
Note
you can call the pageHeader() method only if you give a different dimension respect to 0 to this attribute
Set the width of the page left bar in millimeters Default value is 0
Set the width of the page right bar in millimeters. Default value is 0
TODO. Default value is None
TODO. You can set it to:
- 'value': (default value) TODO
- 'attribute': TODO
TODO. Default value is 'rows'
Set the starting page number. Default value is 0. It is used in the pageCounter() method to choose the starting number for the page enumeration
A string with the names of the html templates separated by a comma. More information in the TODO section of the html template page
A class that transforms a Bag into HTML. It can be used to make a print
override for special needs
override for special needs
override for special needs
override for special needs
override for special needs
TODO
TODO
| Parameters: | valuename – the name of the value to copy |
|---|
TODO
TODO
| Parameters: | filepath – the path where html will be saved |
|---|
override this for custom styles
TODO
Hook method. Define the footer of the doc in the print layout file
| Parameters: |
|
|---|
Note
the method is called only if the doc_footer_height has a value different from 0
Hook method. Define the header of the doc in the print layout file
| Parameters: | header – the header object |
|---|
The docHeader() method allows to receive an object called header to which you can append a layout structure made by layouts, rows, and cells
Note
the method is called only if the doc_header_height has a value different from 0
TODO
| Parameters: |
|
|---|
TODO
Make a getItem() on data if ... TODO
| Parameters: |
|
|---|
TODO
| Parameters: | templates – TODO |
|---|
Get the “css_requires” webpage variable in its string format and return it as a list
It can be overridden
| Parameters: | row – the grid row |
|---|
It can be overridden
| Parameters: | row – the grid row |
|---|
Hook method. MANDATORY if you define a grid in your print. Through this method you receive the center of the page and you can define the layout of the grid
| Parameters: | grid – the grid |
|---|
A init hook method
TODO
It can be overridden
Hook method that must be overridden. It gives the page object to which you have to append a layout
| Parameters: | page – the page object |
|---|
TODO
Hook method.
| Parameters: | recordBag – a Bag that contains the result of the batch |
|---|
Hook method. Allow to define the query to be executed for the print
Example:
def onRecordLoaded(self):
where = '$date >= :begin_date AND $date <= :end_date AND doctor_id=:d_id'
columns ='''$doctor,$date,$hour,$patient,$performance,
@convention_id.code AS convention_code,
$amount,$cost,@invoice_id.number AS invoice'''
query = self.db.table(self.rows_table).query(columns=columns, where=where,
begin_data = self.getData('period.from'),
end_data = self.getData('period.to'),
d_id=self.record['id'])
selection = query.selection()
if not selection:
return False
self.setData('rows',selection.output('grid'))
Set the page orientation to ‘Landscape’ if the page_width is greater than the page_height, else set the orientation to ‘Portrait’
Set the filename extension and return it
| Parameters: | ext – the filename extension |
|---|
Allow to automatically number the pages created in a print. You can choose the format output with the mask parameter
| Parameters: | mask – format output of the pageCounter method. By default is '%s/%s' Example: if you print three pages then they will be numbered as 1/3, 2/3 and 3/3 Syntax: You can alternatively set it as '%s of %s', '%s - %s' and so on |
|---|
Hook method. Define the footer of the page in the print layout file
| Parameters: |
|
|---|
Note
the method is called only if the page_footer_height has a value different from 0
Hook method. Define the header of the page in the print layout file
| Parameters: | header – the header object |
|---|
Note
the method is called only if the page_header_height has a value different from 0
Set the correct value of every measure of the page: height, width, header, footer, margins
Allow to get data from record. You can use it in the prepareRow() method
| Parameters: |
|
|---|
TODO
| Parameters: | path – TODO |
|---|
Make a setItem() on data
| Parameters: |
|
|---|
Set a template.
| Parameters: | templates – TODO |
|---|
TODO
| Parameters: | value – TODO |
|---|
TODO
| Parameters: |
|
|---|