Add support for "new-style grids" and "model master views".
Finally, an API that makes some sense... We don't yet have feature parity with the old-style grids and CRUD views, but this is already a significant improvement to the design. Still needs a lot of docs though...
This commit is contained in:
parent
62b7194c21
commit
585eb09bec
26 changed files with 2296 additions and 94 deletions
78
docs/api/views/master.rst
Normal file
78
docs/api/views/master.rst
Normal file
|
@ -0,0 +1,78 @@
|
|||
.. -*- coding: utf-8 -*-
|
||||
|
||||
``tailbone.views.master``
|
||||
=========================
|
||||
|
||||
.. module:: tailbone.views.master
|
||||
|
||||
Model Master View
|
||||
------------------
|
||||
|
||||
This module contains the "model master" view class. This is a convenience
|
||||
abstraction which provides some patterns/consistency for the typical set of
|
||||
views needed to expose a table's data for viewing/editing/etc. Usually this
|
||||
means providing something like the following view methods for a model:
|
||||
|
||||
* index (list/filter)
|
||||
* create
|
||||
* view
|
||||
* edit
|
||||
* delete
|
||||
|
||||
The actual list of provided view methods will depend on usage. Generally
|
||||
speaking, each view method which is provided by the master class may be
|
||||
configured in some way by the subclass (e.g. add extra filters to a grid).
|
||||
|
||||
.. autoclass:: MasterView
|
||||
|
||||
.. automethod:: index
|
||||
|
||||
.. automethod:: create
|
||||
|
||||
.. automethod:: view
|
||||
|
||||
.. automethod:: edit
|
||||
|
||||
.. automethod:: delete
|
||||
|
||||
Attributes to Override
|
||||
----------------------
|
||||
|
||||
The following is a list of attributes which you can (and in some cases must)
|
||||
override when defining your subclass.
|
||||
|
||||
.. attribute:: MasterView.model_class
|
||||
|
||||
All master view subclasses *must* define this attribute. Its value must
|
||||
be a data model class which has been mapped via SQLAlchemy, e.g.
|
||||
``rattail.db.model.Product``.
|
||||
|
||||
.. attribute:: MasterView.normalized_model_name
|
||||
|
||||
Name of the model class which has been "normalized" for the sake of usage
|
||||
as a key (for grid settings etc.). If not defined by the subclass, the
|
||||
default will be the lower-cased model class name, e.g. 'product'.
|
||||
|
||||
.. attribute:: grid_key
|
||||
|
||||
Unique value to be used as a key for the grid settings, etc. If not
|
||||
defined by the subclass, the normalized model name will be used.
|
||||
|
||||
.. attribute:: MasterView.route_prefix
|
||||
|
||||
Value with which all routes provided by the view class will be prefixed.
|
||||
If not defined by the subclass, a default will be constructed by simply
|
||||
adding an 's' to the end of the normalized model name, e.g. 'products'.
|
||||
|
||||
.. attribute:: MasterView.grid_factory
|
||||
|
||||
Factory callable to be used when creating new grid instances; defaults to
|
||||
:class:`tailbone.newgrids.alchemy.AlchemyGrid`.
|
||||
|
||||
.. Methods to Override
|
||||
.. -------------------
|
||||
..
|
||||
.. The following is a list of methods which you can override when defining your
|
||||
.. subclass.
|
||||
..
|
||||
.. .. automethod:: MasterView.get_settings
|
Loading…
Add table
Add a link
Reference in a new issue