From fa8829b18e65111e7ac765bc32041362e259c3c0 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Mon, 4 Nov 2013 13:35:44 -0600 Subject: [PATCH] all subclasses of SchemaNode need a ``typ`` also the docs are confusing with you do: from colander import SchemaNode and then in the same code block you use ``colander.Range``, so I formalized everything to use ``colander.*`` syntax. --- docs/basics.rst | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/docs/basics.rst b/docs/basics.rst index aee7b82..83c862c 100644 --- a/docs/basics.rst +++ b/docs/basics.rst @@ -170,9 +170,8 @@ The imperative style that looks like this still works, of course: .. code-block:: python - from colander import SchemaNode - ranged_int = colander.SchemaNode( + typ=colander.Int(), validator=colander.Range(0, 10), default=10, title='Ranged Int' @@ -182,9 +181,8 @@ But in 1.0a1+, you can alternately now do something like this: .. code-block:: python - from colander import SchemaNode - - class RangedInt(SchemaNode): + class RangedInt(colander.SchemaNode): + typ = colander.Int() validator = colander.Range(0, 10) default = 10 title = 'Ranged Int' @@ -196,9 +194,8 @@ the schemanode subclass instead of plain attributes: .. code-block:: python - from colander import SchemaNode - - class RangedInt(SchemaNode): + class RangedInt(colander.SchemaNode): + typ = colander.Int() default = 10 title = 'Ranged Int' @@ -222,9 +219,8 @@ example this will *not* work: .. code-block:: python - from colander import SchemaNode - - class RangedInt(SchemaNode): + class RangedInt(colander.SchemaNode): + typ = colander.Int() default = 10 title = 'Ranged Int' @@ -250,9 +246,8 @@ indeed work): .. code-block:: python - from colander import SchemaNode - - class RangedInt(SchemaNode): + class RangedInt(colander.SchemaNode): + typ = colander.Int() default = 10 title = 'Ranged Int' @@ -275,9 +270,8 @@ the bind parameters within values that are plain old methods: .. code-block:: python - from colander import SchemaNode - - class RangedInt(SchemaNode): + class RangedInt(colander.SchemaNode): + typ = colander.Int() default = 10 title = 'Ranged Int' @@ -297,9 +291,8 @@ attributes of the schemanode that rely on binding variables: .. code-block:: python - from colander import SchemaNode - - class UserIdSchemaNode(SchemaNode): + class UserIdSchemaNode(colander.SchemaNode): + typ = colander.String() title = 'User Id' def after_bind(self, node, kw): @@ -310,9 +303,8 @@ constructor: .. code-block:: python - from colander import SchemaNode - - class RangedInt(SchemaNode): + class RangedInt(colander.SchemaNode): + typ = colander.Int() default = 10 title = 'Ranged Int' validator = colander.Range(0, 10)