Helper base class that picks principal ids.
Add numbers to ids given by users to make them unique.
The Id picker is a variation on the name chooser that picks numeric ids when no name is given.
>>> from zope.app.authentication.idpicker import IdPicker >>> IdPicker({}).chooseName('', None) u'1'>>> IdPicker({'1': 1}).chooseName('', None) u'2'>>> IdPicker({'2': 1}).chooseName('', None) u'1'>>> IdPicker({'1': 1}).chooseName('bob', None) u'bob'>>> IdPicker({'bob': 1}).chooseName('bob', None) u'bob1'
There are no attributes in this class.
checkName(name, object)
Limit ids
Ids can only contain printable, non-space, 7-bit ASCII strings:
>>> from zope.app.authentication.idpicker import IdPicker
>>> IdPicker({}).checkName(u'1', None)
True
>>> IdPicker({}).checkName(u'bob', None)
True
>>> IdPicker({}).checkName(u'bobĂș', None)
... # doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
UserError: Ids must contain only printable
7-bit non-space ASCII characters
>>> IdPicker({}).checkName(u'big bob', None)
... # doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
UserError: Ids must contain only printable
7-bit non-space ASCII characters
Ids also can't be over 100 characters long:
>>> IdPicker({}).checkName(u'x' * 100, None)
True
>>> IdPicker({}).checkName(u'x' * 101, None)
Traceback (most recent call last):
...
UserError: Ids can't be more than 100 characters long.
chooseName(name, object)
There are no known subclasses.