Package s3 :: Package codecs :: Module card :: Class S3PDFCard
[frames] | no frames]

Class S3PDFCard

source code

     object --+    
              |    
s3codec.S3Codec --+
                  |
                 S3PDFCard

Codec to produce printable data cards (e.g. ID cards)

Instance Methods
 
encode(self, resource, **attr)
API Method to encode a resource as cards
source code
 
extract(self, resource, fields, orderby=None)
Extract the data items from the given resource
source code
 
get_flowables(self, layout, resource, items, labels=None, cards_per_page=1)
Get the Flowable-instances for the data items
source code

Inherited from s3codec.S3Codec: decode

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods

Inherited from s3codec.S3Codec: get_codec, xml_decode, xml_encode

Static Methods

Inherited from s3codec.S3Codec: crud_string, json_message

Class Variables

Inherited from s3codec.S3Codec: CODECS, PY2XML, XML2PY, indices

Properties

Inherited from object: __class__

Method Details

encode(self, resource, **attr)

source code 

API Method to encode a resource as cards

Parameters:
  • resource - the S3Resource, or
    • the data items as list [{fieldname: representation, ...}, ...], or
    • a callable that produces such a list of items
  • attr - additional encoding parameters (see below)
  • layout - the layout (a S3PDFCardLayout subclass, overrides the resource's pdf_card_layout setting
  • orderby - orderby-expression for data extraction, overrides the resource's orderby setting
  • labels - the labels for the fields,
    • a dict {colname: label}, or
    • a callable that produces it,
    • defaults to the labels of the extracted fields
  • pagesize - the PDF page size,
    • a string "A4" or "Letter", or
    • a tuple (width, height), in points
    • defaults to the layout's card size
  • margins - the page margins,
    • a tuple (N, E, S, W), in points, or
    • a single number, in points
    • will be computed if omitted
  • spacing - the spacing between cards,
    • a tuple (H, V), in points, or
    • a single number, in points
    • defaults to 18 points in both directions
  • title - the document title,
    • defaults to title_list crud string of the resource
Returns:
a handle to the output
Overrides: s3codec.S3Codec.encode

extract(self, resource, fields, orderby=None)

source code 

Extract the data items from the given resource

Parameters:
  • resource - the resource (a filtered S3Resource)
  • fields - the fields to extract (array of field selectors)
  • orderby - the orderby-expression
Returns:
an S3ResourceData instance

get_flowables(self, layout, resource, items, labels=None, cards_per_page=1)

source code 

Get the Flowable-instances for the data items

Parameters:
  • layout - the S3PDFCardLayout subclass implementing the card layout
  • resource - the resource
  • items - the data items
  • labels - the field labels
  • cards_per_page - the number of cards per page