Class
zope.configuration.fields.PythonIdentifier

This field describes a python identifier, i.e. a variable name.

Let's look at an example:

>>> class FauxContext(object):
...     pass
>>> context = FauxContext()
>>> field = PythonIdentifier().bind(context)

Let's test the fromUnicode method:

>>> field.fromUnicode(u'foo')
u'foo'
>>> field.fromUnicode(u'foo3')
u'foo3'
>>> field.fromUnicode(u'_foo3')
u'_foo3'

Now let's see whether validation works alright

>>> for value in (u'foo', u'foo3', u'foo_', u'_foo3', u'foo_3', u'foo3_'):
...     field._validate(value)
>>>
>>> from zope import schema
>>>
>>> for value in (u'3foo', u'foo:', u'\\', u''):
...     try:
...         field._validate(value)
...     except schema.ValidationError:
...         print 'Validation Error'
Validation Error
Validation Error
Validation Error
Validation Error

Base classes

Implemented Interfaces

Attributes/Properties

Methods

Known Subclasses

There are no known subclasses.