Package gchecky :: Module gxml :: Class List
[hide private]
[frames] | no frames]

Class List

source code

object --+    
         |    
     Field --+
             |
            List

The field describes a homogene list of values which could be stored as a set of XML nodes with the same tag names.

An example - list of strings which should be stored as <messages> <message />* </messages>?:
 class ...:
     ...
     messages = gxml.List('/messages', gxml.String('/message'), required=False)


Instance Methods [hide private]
 
__init__(self, path, list_item, empty_is_none=True, **kwargs)
Initializes the List instance.
source code
 
validate(self, data)
Checks that the data is a valid sequence.
source code
 
save(self, node, data)
Store the data list in a DOM node.
source code
 
load(self, node)
Load the list from the xml DOM node.
source code
 
__repr__(self)
Override Field.__repr__ for documentation purposes
source code

Inherited from Field: create_node_for_path, data2str, get_any_node_for_path, get_initial_value, get_nodes_for_path, get_one_node_for_path, str2data

Inherited from Field (private): _traits

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Class Methods [hide private]

Inherited from Field: deconstruct_path, reconstruct_path

Class Variables [hide private]
  list_item = None
a Field instance describing this list items.
Instance Variables [hide private]

Inherited from Field: default, empty, path, required, save_node_and_xml, values

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, path, list_item, empty_is_none=True, **kwargs)
(Constructor)

source code 
Initializes the List instance.
Parameters:
  • path - Field.path
  • list_item - a meta-Field instance describing the list items
  • empty_is_none - If True then when loading data an empty list [] would be treated as None value. True by default.
Overrides: Field.__init__

validate(self, data)

source code 
Checks that the data is a valid sequence.
Overrides: Field.validate

save(self, node, data)

source code 
Store the data list in a DOM node.
Parameters:
  • node - the xml DOM node to hold the list
  • data - a list of items to be stored
Overrides: Field.save

load(self, node)

source code 
Load the list from the xml DOM node.
Parameters:
  • node - the xml DOM node containing the list.
Returns:
a list of items.
Overrides: Field.load

__repr__(self)
(Representation operator)

source code 
Override Field.__repr__ for documentation purposes
Overrides: Field.__repr__