diff --git a/docs/api/wuttaweb/grids.base.rst b/docs/api/wuttaweb/grids.base.rst new file mode 100644 index 0000000..8b3cc38 --- /dev/null +++ b/docs/api/wuttaweb/grids.base.rst @@ -0,0 +1,6 @@ + +``wuttaweb.grids.base`` +======================= + +.. automodule:: wuttaweb.grids.base + :members: diff --git a/docs/api/wuttaweb/grids.rst b/docs/api/wuttaweb/grids.rst new file mode 100644 index 0000000..7430a21 --- /dev/null +++ b/docs/api/wuttaweb/grids.rst @@ -0,0 +1,6 @@ + +``wuttaweb.grids`` +================== + +.. automodule:: wuttaweb.grids + :members: diff --git a/docs/api/wuttaweb/index.rst b/docs/api/wuttaweb/index.rst index 5afd18b..1b1a61f 100644 --- a/docs/api/wuttaweb/index.rst +++ b/docs/api/wuttaweb/index.rst @@ -12,6 +12,8 @@ db forms forms.base + grids + grids.base handler helpers menus diff --git a/src/wuttaweb/forms/__init__.py b/src/wuttaweb/forms/__init__.py index 35102be..0f72808 100644 --- a/src/wuttaweb/forms/__init__.py +++ b/src/wuttaweb/forms/__init__.py @@ -26,6 +26,7 @@ Forms Library The ``wuttaweb.forms`` namespace contains the following: * :class:`~wuttaweb.forms.base.Form` +* :class:`~wuttaweb.forms.base.FieldList` """ -from .base import Form +from .base import Form, FieldList diff --git a/src/wuttaweb/forms/base.py b/src/wuttaweb/forms/base.py index 42abb31..89664e3 100644 --- a/src/wuttaweb/forms/base.py +++ b/src/wuttaweb/forms/base.py @@ -44,7 +44,8 @@ class FieldList(list): of :class:`python:list`. You normally would not need to instantiate this yourself, but it - is used under the hood for e.g. :attr:`Form.fields`. + is used under the hood for :attr:`Form.fields` as well as + :attr:`~wuttaweb.grids.base.Grid.columns`. """ def insert_before(self, field, newfield): @@ -105,15 +106,48 @@ class Form: Form instances contain the following attributes: + .. attribute:: request + + Reference to current :term:`request` object. + .. attribute:: fields :class:`FieldList` instance containing string field names for the form. By default, fields will appear in the same order as they are in this list. - .. attribute:: request + .. attribute:: schema - Reference to current :term:`request` object. + Colander-based schema object for the form. This is optional; + if not specified an attempt will be made to construct one + automatically. + + See also :meth:`get_schema()`. + + .. attribute:: model_class + + Optional "class" for the model. If set, this usually would be + a SQLAlchemy mapped class. This may be used instead of + specifying the :attr:`schema`. + + .. attribute:: model_instance + + Optional instance from which initial form data should be + obtained. In simple cases this might be a dict, or maybe an + instance of :attr:`model_class`. + + Note that this also may be used instead of specifying the + :attr:`schema`, if the instance belongs to a class which is + SQLAlchemy-mapped. (In that case :attr:`model_class` can be + determined automatically.) + + .. attribute:: readonly + + Boolean indicating the form does not allow submit. In practice + this means there will not even be a ``