The pyck.lib Package

class pyck.lib.color_logger.ColorLogger(name, output_file=<open file '<stdout>', mode 'w'>, error_file=<open file '<stderr>', mode 'w'>)

Logger class that by default outputs to stderr

class pyck.lib.color_logger.ConsoleColorHandler(stream=None)

Log Handler for console that outputs colored log messages according to their severity

Models related utility functions

pyck.lib.models.get_columns(model, col_type=None)

Returns column objects of the current model

Parameters:col_type – (Optional) The type of columns to return. Currently supported types are ‘primary_key’ and ‘foreign_key’
pyck.lib.models.get_model_record_counts(db_session, models)

returns record counts for given models

pyck.lib.models.get_models(application, get_app_models=True, return_dict=False, ignore_auth_tables=True)

Processes the passed application package and returns all SQLAlchemy models for the application.

Parameters:get_app_models – Indicates if the apps present in the application should also be searched for models (default True)

Given a models dict containing subapp names as keys and models as a list of values return an aggregated list of all models

pyck.lib.pagination.get_pages(total_recs, current_page, recs_per_page=10, max_pages=10)

A utility function that returns the pages (for records pagination display purposes)

  • total_recs – Total number of records
  • current_page – Current page that is being displayed
  • recs_per_page – Number of records being displayed per page
  • max_pages – Maximum number of pages to return

Returns a list containing pages that should be displayed as page links.

Packages related utility functions


Returns all sub-modules of a package also indicating if the module is also a package Return a list with each item being a dictionary with keys name (String) and is_package (Boolean)

Routes related utility functions


Returns OrderedDict of routes available for given request

Parameters:request – Request object (normally called from controller code)
Returns:OrderedDict of routes with routename as key and route url as value