cardinal_pythonlib.deform_utils
Original code copyright (C) 2009-2022 Rudolf Cardinal (rudolf@pobox.com).
This file is part of cardinal_pythonlib.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- class cardinal_pythonlib.deform_utils.DeformErrorInterface(msg: str, *children: DeformErrorInterface)[source]
Class to record information about Deform errors.
- class cardinal_pythonlib.deform_utils.DynamicDescriptionsForm(*args, dynamic_descriptions: bool = True, dynamic_titles: bool = False, **kwargs)[source]
For explanation, see
cardinal_pythonlib.colander_utils.ValidateDangerousOperationNode
.In essence, this allows a schema to change its
description
properties during form validation, and then to have them reflected in the form (which won’t happen with a standard DeformForm
, since it normally copies its descriptions from its schema at creation time).The upshot is that we can store temporary values in a form and validate against them.
The use case is to generate a random string which the user has to enter to confirm dangerous operations.
- Parameters:
args¶ – other positional arguments to
InformativeForm
dynamic_descriptions¶ – use dynamic descriptions?
dynamic_titles¶ – use dynamic titles?
kwargs¶ – other keyword arguments to
InformativeForm
- class cardinal_pythonlib.deform_utils.InformativeForm(schema, action='', method='POST', buttons=(), formid='deform', use_ajax=False, ajax_options='{}', autocomplete=None, focus='on', **kw)[source]
A Deform form class that shows its errors.
- cardinal_pythonlib.deform_utils.debug_validator(validator: Callable[[SchemaNode, Any], None]) Callable[[SchemaNode, Any], None] [source]
Use as a wrapper around a validator, e.g.
self.validator = debug_validator(OneOf(["some", "values"]))
If you do this, the log will show the thinking of the validator (what it’s trying to validate, and whether it accepted or rejected the value).