This fields represents a menu (item type).
Besides being able to look up the menu by importing it, we also try to look up the name in the site manager.
>>> from zope.interface import directlyProvides >>> from zope.interface.interface import InterfaceClass
>>> menu1 = InterfaceClass('menu1', (), ... __doc__='Menu Item Type: menu1', ... __module__='zope.app.menus') >>> directlyProvides(menu1, IMenuItemType)
>>> menus = None >>> class Resolver(object): ... def resolve(self, path): ... if path.startswith('zope.app.menus') and \ ... hasattr(menus, 'menu1') or \ ... path == 'zope.app.component.menus.menu1': ... return menu1 ... raise ConfigurationError('menu1')
>>> field = MenuField() >>> field = field.bind(Resolver())
>>> field.fromUnicode('zope.app.component.menus.menu1') is menu1 True
>>> from types import ModuleType as module >>> import sys >>> menus = module('menus') >>> old = sys.modules.get('zope.app.menus', None) >>> sys.modules['zope.app.menus'] = menus >>> setattr(menus, 'menu1', menu1)
>>> field.fromUnicode('menu1') is menu1 True
>>> if old is not None: ... sys.modules['zope.app.menus'] = old
>>> from zope.app.testing import ztapi >>> ztapi.provideUtility(IMenuItemType, menu1, 'menu1')
>>> field.fromUnicode('menu1') is menu1 True
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
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.