Package EaseXML :: Module Nodes :: Class ChoiceNode
[show private | hide private]
[frames | no frames]

Type ChoiceNode

object --+    
         |    
      Node --+
             |
            ChoiceNode


Alternative Nodes

Right recursivity is permitted, but left recursions are (I hope so) prohibited. In the following example, mix can be an Item or a Blah object:

class Item(XMLObject):
    pass

class Blah(XMLObject):
    mix = ChoiceNode(['Item','Blah'])

One can also use the special '#PCDATA' alternative:

class Blah(XMLObject):
    mix = ChoiceNode(['#PCDATA', 'Item'])

So mix can be either a string or an Item instance. noLimit keyword can be set to True when the node has to bahave as a List. Setting optional to True, XMLObject won't complain if it's empty.


Method Summary
  __init__(self, choiceAlternatives, optional, noLimit, main)
  checkForLeftRecursivity(self, xmlObject, nodeName)
  checkType(self, val)
Type checking.
  getValueFromDom(self, dom, attrName, **kw)
  resetValue(self)
  setValue(self, value)
  xmlrepr(self, parentInstance)
XML representation of the Node
    Inherited from Node
  getDefaultValue(self)
  getItemType(self)
  getName(self)
  getParentType(self)
  getRegistry(self)
  getType(self)
  getValue(self)
  isMain(self)
  isNoLimit(self)
  isOptional(self)
  setDefaultValue(self, default)
  setItemType(self, type)
  setMain(self, m)
  setName(self, name)
  setNoLimit(self, val)
  setOptional(self, val)
  setParentType(self, parentType)
  setRegistry(self, reg)
  setType(self, type)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Method Details

checkType(self, val)

Type checking.

val is object to check. If checkType returns False, a TypeError is raised to claim that Node value assignment is not valid. Either, checkType should return an optionally modified version of val (usefull when dealing with lists assignements where items should be XMLObject instances).

Overrides:
EaseXML.Node.Node.checkType (inherited documentation)

xmlrepr(self, parentInstance=None)

XML representation of the Node

Returns a string representing the Node as XML data.

Overrides:
EaseXML.Node.Node.xmlrepr (inherited documentation)

Generated by Epydoc 2.1 on Sun Dec 12 17:20:24 2004 http://epydoc.sf.net