
Node
====

Short test on superclass

  >>> from zope.interface.common.mapping import IFullMapping
  >>> from zodict import zodict
  >>> zod = zodict()
  >>> IFullMapping.providedBy(zod)
  True

We have a base node which provides the default interface implementation.

  >>> from zope.interface.common.mapping import IFullMapping
  >>> from zodict.interfaces import INode
  >>> from zodict.node import Node
  >>> root = Node('root')
  >>> root
  <Node object 'root' at ...>
  
  >>> root.__name__
  'root'
  
  >>> root.__parent__

  >>> root.path
  ['root']
  
  >>> root['child'] = Node()
  >>> root['child'].path
  ['root', 'child']
  
  >>> root['child']['subchild'] = Node()
  >>> root['child']['subchild'].path
  ['root', 'child', 'subchild']
  
  >>> root['child']['subchild2'] = Node()
  >>> root.keys()
  ['child']
  
  >>> root['child'].keys()
  ['subchild', 'subchild2']
  
  >>> root['child'].items()
  [('subchild', <Node object 'subchild' at ...>), 
  ('subchild2', <Node object 'subchild2' at ...>)]
  
  >>> child = root['child']
  >>> child.__name__
  'child'
  
  >>> child.__parent__
  <Node object 'root' at ...>

Test filtereditems function

  >>> from zope.interface import Interface
  >>> from zope.interface import alsoProvides
  >>> class IMarker(Interface): pass
  >>> alsoProvides(root['child']['subchild'], IMarker)
  >>> IMarker.providedBy(root['child']['subchild'])
  True
  
  >>> for item in root['child'].filtereditems(IMarker):
  ...     print item.path
  ['root', 'child', 'subchild']