Package turbogears :: Module paginate'

Module paginate'

source code

Classes
  Paginate
Class for paginate variable provider.
  attrwrapper
Helper class for accessing object attributes.
  itemwrapper
Helper class for dictionary access.
Functions
 
paginate(var_name, default_order='', limit=10, max_limit=0, max_pages=5, max_sort=1000, dynamic_limit=None)
The famous TurboGears paginate decorator.
source code
 
sort_data(data, ordering, in_memory=True)
Sort data based on ordering.
source code
 
sort_ordering(ordering, sort_name)
Rearrange ordering based on sort_name.
source code
 
sql_get_column(colname, var_data)
Return a column from var_data based on colname.
source code
 
sql_order_col(col, ascending=True)
Return an ordered column for col.
source code
 
sqlalchemy_get_column(colname, var_data, join_props=None)
Return a column from SQLAlchemy var_data based on colname.
source code
 
sqlalchemy_join_props(var_data, join_props)
Return a query where all tables for properties are joined.
source code
 
sqlalchemy_order_col(col, descending=False)
Return an SQLAlchemy ordered column for col.
source code
 
sqlobject_get_column(colname, var_data, join_props=None)
Return a column from SQLObject var_data based on colname.
source code
 
sqlobject_order_col(col, descending=False)
Return an SQLObject ordered column for col.
source code
Variables
  __package__ = 'turbogears'
  log = <logging.Logger instance at 0x1c437e8>
  sqlalchemy_before_0_5 = False
  variable_providers = []
Function Details

paginate(var_name, default_order='', limit=10, max_limit=0, max_pages=5, max_sort=1000, dynamic_limit=None)

source code 

The famous TurboGears paginate decorator.

Parameters:
  • var_name (string) - the variable name that the paginate decorator will try to control. This key must be present in the dictionary returned from your controller in order for the paginate decorator to be able to handle it.
  • default_order (string or a list of strings. Any string starting with "-" (minus sign) indicates a reverse order for that field/column.) - The column name(s) that will be used to order pagination results. Due to the way pagination is implemented specifying a default_order will override any result ordering performed in the controller.
  • limit (integer) - The hard-coded limit that the paginate decorator will impose on the number of "var_name" to display at the same time. This value can be overridden by the use of the dynamic_limit keyword argument.
  • max_limit (int) - The maximum number to which the imposed limit can be increased using the "var_name"_tgp_limit keyword argument in the URL. If this is set to 0, no dynamic change at all will be allowed; if it is set to None, any change will be allowed.
  • max_pages (integer) - Used to generate the tg.paginate.pages variable. If the page count is larger than max_pages, tg.paginate.pages will only contain the page numbers surrounding the current page at a distance of max_pages/2. A zero value means that all pages will be shown, no matter how much.
  • max_sort (integer) - The maximum number of records that will be sorted in memory if the data cannot be sorted using SQL. If set to 0, sorting in memory will never be performed; if set to None, no limit will be imposed.
  • dynamic_limit (string) - If specified, this parameter must be the name of a key present in the dictionary returned by your decorated controller. The value found for this key will be used as the limit for our pagination and will override the other settings, the hard-coded one declared in the decorator itself AND the URL parameter one. This enables the programmer to store a limit settings inside the application preferences and then let the user manage it.

sort_data(data, ordering, in_memory=True)

source code 

Sort data based on ordering.

Tries to sort the data using SQL whenever possible, otherwise sorts the data as list in memory unless in_memory is false.