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:
Lance Edgar 2015-07-29 11:09:38 -05:00
parent 62b7194c21
commit 585eb09bec
26 changed files with 2296 additions and 94 deletions

10
docs/api/newgrids.rst Normal file
View file

@ -0,0 +1,10 @@
.. -*- coding: utf-8 -*-
``tailbone.newgrids``
=====================
.. automodule:: tailbone.newgrids
:members:
.. automodule:: tailbone.newgrids.alchemy
:members:

78
docs/api/views/master.rst Normal file
View 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

View file

@ -34,9 +34,14 @@ execfile(os.path.join(os.pardir, 'tailbone', '_version.py'))
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
]
intersphinx_mapping = {
'formalchemy': ('http://docs.formalchemy.org/formalchemy/', None),
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@ -51,7 +56,7 @@ master_doc = 'index'
# General information about the project.
project = u'Tailbone'
copyright = u'2014, Lance Edgar'
copyright = u'2015, Lance Edgar'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@ -105,7 +110,7 @@ pygments_style = 'sphinx'
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the

View file

@ -22,8 +22,10 @@ Package API:
.. toctree::
:maxdepth: 1
api/newgrids
api/subscribers
api/views/batch
api/views/master
api/views/vendors.catalogs