Trees | Index | Help |
|
---|
Package zope :: Package configuration :: Module fields :: Class PythonIdentifier |
|
object
--+ |Element
--+ |Attribute
--+ |Field
--+ |object
--+ | | |MinMaxLen
--+ |Text
--+ |TextLine
--+ | 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
Method Summary | |
---|---|
fromUnicode(self,
u)
| |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__repr__() <==> repr(x) | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Class Variable Summary | |
---|---|
Implements |
__implemented__ = <implementedBy zope.configuration.fiel...
|
ClassProvides |
__provides__ = <zope.interface.declarations.ClassProvide...
|
Class Variable Details |
---|
__implemented__
|
__provides__
|
Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Jun 24 12:01:20 2005 | http://epydoc.sf.net |