Skip to content

Commit 5ba96e4

Browse files
authored
Merge pull request #516 from Pylons/docs-add-api-csrfschema
Add CSRFSchema to API docs
2 parents 6aafc36 + 632a834 commit 5ba96e4

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

deform/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from .field import Field # API
99
from .form import Button # API
1010
from .form import Form # API
11+
from .schema import CSRFSchema # API
1112
from .schema import FileData # API
1213
from .template import ZPTRendererFactory # API
1314
from .template import default_renderer # API

deform/field.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def __init__(
269269
self.set_appstruct(appstruct)
270270

271271
def found_first(self):
272-
""" Set have_first_input of ancestors """
272+
"""Set have_first_input of ancestors"""
273273
self.have_first_input = True
274274
if self.parent is not None:
275275
self.parent.found_first()
@@ -281,7 +281,7 @@ def parent(self):
281281
return self._parent()
282282

283283
def get_root(self):
284-
""" Return the root field in the field hierarchy (the form field) """
284+
"""Return the root field in the field hierarchy (the form field)"""
285285
node = self
286286
while True:
287287
parent = node.parent
@@ -353,7 +353,7 @@ def translate(self, msgid):
353353
return msgid
354354

355355
def __iter__(self):
356-
""" Iterate over the children fields of this field. """
356+
"""Iterate over the children fields of this field."""
357357
return iter(self.children)
358358

359359
def __getitem__(self, name):
@@ -626,7 +626,7 @@ def serialize(self, cstruct=_marker, **kw):
626626
return self.widget.serialize(**values)
627627

628628
def deserialize(self, pstruct):
629-
""" Deserialize the pstruct into a cstruct and return the cstruct."""
629+
"""Deserialize the pstruct into a cstruct and return the cstruct."""
630630
return self.widget.deserialize(self, pstruct)
631631

632632
def render(self, appstruct=_marker, **kw):

deform/schema.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,25 @@ class CSRFSchema(colander.Schema):
141141
142142
.. code-block:: python
143143
144-
import colander
145-
from deform.schema import CSRFSchema
144+
import colander
145+
from deform.schema import CSRFSchema
146146
147-
class MySchema(CSRFSchema):
148-
my_field = colander.SchemaNode(colander.String())
147+
class MySchema(CSRFSchema):
148+
my_field = colander.SchemaNode(colander.String())
149149
150150
And in your application code, *bind* the schema, passing the request as a
151151
keyword argument:
152152
153153
.. code-block:: python
154154
155-
def view(request):
156-
schema = MySchema().bind(request=request)
155+
def view(request):
156+
schema = MySchema().bind(request=request)
157157
158158
When using Pyramid 1.7+, the CSRF token is validated by CSRF view deriver.
159159
160160
More information
161161
162-
https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/sessions.html#checking-csrf-tokens-automatically # noqa: E501
162+
https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/security.html#checking-csrf-tokens-automatically
163163
"""
164164

165165
csrf_token = colander.SchemaNode(

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Type-Related
2929
.. autoclass:: FileData
3030
:members:
3131

32+
.. autoclass:: CSRFSchema
33+
:members:
34+
3235
See also the type- and schema-related documentation in :term:`Colander`.
3336

3437
Exception-Related

0 commit comments

Comments
 (0)