The PyCK Admin Interface

PyCK Admin Extension

Admin extension that automtically creates CRUD interfaces for all database models (or a selected list of models)

class pyck.ext.admin_controller.AdminController(request)

Enables automatic Admin interface generation from database models. The pyck.ext.admin_controller.AdminController allows you to quickly enable Admin interface for any number of database models you like. To use AdminController at minimum these steps must be followed.

1. In your application’s routes settings, specify the url where the CRUD interface should be displayed. You can use the pyck.ext.admin_controller.add_admin_handler() function for it. For example in your __init__.py; put code like:

from pyck.ext import AdminController, add_admin_handler
from pyck.lib import get_models
import my_application_package_name_here

# Place this with the config.add_route calls
add_admin_handler(config, DBSession, get_models(my_application_package_name_here), 'admin', '/admin',
                  AdminController)

and that’s all you need to do to get a fully operation Admin interface.

Configuration Options

These parameters are to be set as class properties in a sub-class of AdminController

TODO

  • More documentation of various options and methods
  • An AdminController tutorial
  • Tests for the controller
  • Add support for composite primary keys
pyck.ext.admin_controller.add_admin_handler(config, db_session, models=None, route_name_prefix='', url_pattern_prefix='', handler_class=None, models_field_args={})

A utility function to quickly add all admin related routes and set them to the admin handler class with one function call, for example:

from pyck.ext import add_admin_handler, AdminController
from pyck.lib import get_models
import my_application_package_name_here

# Place this with the config.add_route calls
add_admin_handler(config, DBSession, get_models(my_application_package_name_here), 'admin', '/admin',
                  AdminController)
Parameters:
  • config – The application config object
  • DBSession – The database session object
  • models – List of models for to include in the admin panel. get_models funcion can be used to include all models.
  • route_name_prefix – Optional string prefix to add to all route names generated inside the admin panel.
  • url_pattern_prefix – Optional string prefix to add to all admin section related url patterns
  • handler_class – The AdminController handler class.
  • models_field_args

    A dictionary with key being the model name and value being the field args value for that model.

    Example:

    model_field_args = {‘Product’: {‘category_id’ : {
    ‘widget’ : Select()

    }

    },

    ‘Category’: {‘description’ : {
    ‘widget’ : TextArea()

    }

    },

    }

Table Of Contents

Previous topic

The pyck.controllers Package

Next topic

The pyck.lib Package

This Page