This field describes a permission.
Let's look at an example:
>>> class FauxContext(object): ... permission_mapping = {'zope.ManageCode':'zope.private'} ... _actions = [] ... def action(self, **kws): ... self._actions.append(kws) >>> context = FauxContext() >>> field = Permission().bind(context)
Let's test the fromUnicode method:
>>> field.fromUnicode(u'zope.foo') 'zope.foo' >>> field.fromUnicode(u'zope.ManageCode') 'zope.private'
Now let's see whether validation works alright
>>> field._validate('zope.ManageCode') >>> context._actions[0]['args'] (None, 'zope.foo') >>> field._validate('3 foo') Traceback (most recent call last): ... InvalidId: 3 foo
zope.Public is always valid >>> field._validate('zope.Public')
context
(type: NoneType
)
None
default
(type:
ValidatedProperty
)
<zope.schema._bootstrapfields.ValidatedProperty object at 0x40b28f2c>
description
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b223ec>
interface
(type: NoneType
)
None
max_length
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b22ecc>
min_length
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b22e8c>
missing_value
(type: NoneType
)
None
order
(type:
int
)
734
readonly
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b2280c>
required
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b22d0c>
title
(type:
FieldProperty
)
<zope.schema.fieldproperty.FieldProperty object at 0x40b0208c>
bind(object)
constraint(value)
fromUnicode(u)
get(object)
getDoc()
Returns the documentation for the object.
getName()
Returns the name of the object.
getTaggedValue(tag)
Returns the value associated with tag
.
getTaggedValueTags()
Returns a list of all tags.
query(object, default=None)
queryTaggedValue(tag, default=None)
Returns the value associated with tag
.
set(object, value)
setTaggedValue(tag, value)
Associates value
with key
.
validate(value)
There are no known subclasses.