Enables automatic CRUD interface generation from database models. The pyck.controllers.CRUDController allows you to quickly enable CRUD interface for any database model you like. To use CRUD controller at minimum these steps must be followed.
Create a sub-class of the CRUDController and set model (for which you want to have CRUD) and database session:
from pyck.controllers import CRUDController
from myapp.models import MyModel, db
class MyCRUDController(CRUDController):
model = MyModel
db_session = db
In your application’s routes settings, specify the url where the CRUD interface should be displayed. You can use the pyck.controllers.add_crud_handler() method for it. For example in your __init__.py (if you’re enabling CRUD for a model without your main project) or in your routes.py (if you’re enabling CRUD for a model within an app in your project) put code like:
from pyck.controllers import add_crud_handler
from controllers.views import WikiCRDUController
# Place this with the config.add_route calls
add_crud_handler(config, 'mymodel_crud', '/mymodel', WikiCRUDController)
and that’s all you need to do to get a fully operation CRUD interface. Take a look at the newapp sample app in demos for a working CRUD example in the Wiki app.
Configuration Options
These parameters are to be set as class properties in a sub-class of CRUDController
| Parameters: |
|
|---|
TODO
The add record view
The record delete view
TODO:
- Later may need to add support for composite primary keys here.
The record details view
The edit and update record view
The listing view - Lists all the records with pagination
A utility function to quickly add all crud related routes and set them to the crud handler class with one function call, for example:
from pyck.controllers import add_crud_handler
from controllers.views import WikiCRUDController
.
.
.
add_crud_handler(config, APP_NAME + '.', '/crud', WikiCRUDController)
| Parameters: |
|
|---|