RestrictedSize
A simple product to provide limitations to how much text can be entered into a textfield. Currently only supports simple String fields, support for TextAreaWidget variants of String will be added later. Portions of the code generated with paster and copies from original Archetypes code. The rest is Copyright Nidelven IT LTD and released under the GPL, version 2.
Project Description
A simple product to provide limitations to how much text can be entered into a textfield. Currently only supports simple String fields, support for TextAreaWidget variants of String will be added later.
Portions of the code generated with paster and copies from original Archetypes code. The rest is Copyright Nidelven IT LTD and released under the GPL, version 2.
This product was originally created to along with a new widget, monkeypatch the Archetypes settings so that regular String widgets were converted to restricted size widgets. Patching was not easy to do however, so the workaround for now is to modify
Archetypes/generator/widget.py so that it contains
allprops = self._properties.copy()
allprops.update(kwargs)
if allprops.get('macro', '') == 'widgets/string' and\
not allprops.get('disableRestrictedSize', False):
allprops['macro'] = 'restrictedsize_string'
from RestrictedSize import RestrictedSize
if int(allprops.get('maxlength', 255)) == 255:
allprops['maxlength'] = config.maxlength_string
allprops['description'] = config.widget_description
self.__dict__.update(allprops)
This will modify all String-type widgets so that they become size-limited to whatever config.py has set, but it will not alter the labels. So Title will still say Title.
And modify Archetypes/Field.py so that the __init__ method contains
if self._properties['type'] == 'string':
from RestrictedSize.RestrictedSize import validators # triggers registration of validator
self._properties['validators'] = self._properties['validators'] + ('ValidateRestrictedSize',)
at the very beginning (below the docstring).
This product has been designed to work for visually impaired users as well, and depends on the screenReaderHelp class to be defined to
.screenReaderHelp {
display: none;
}
so that text meant for visually impaired (braille/voice) users doesn't show up for other users.
Created by Morten W. Petersen, <morten@nidelven-it.no>
Current Release
No stable release available yet.
If you are interested in getting the source code of this project, you can get it from the Code repository .
All Releases
| Version | Released | Description | Compatibility | Licenses | Status |
|---|

