Package gnue :: Package common :: Package datasources :: Module GConditions :: Class GCondition
[show private | hide private]

Type GCondition

GTriggerCore --+    
               |    
  object --+   |    
           |   |    
   ParserObj --+    
               |    
            GObj --+
                   |
                  GCondition

Known Subclasses:
GConditionElement, GRConditions

A GCondition instance is allways the root node of a condition tree. All children of a GCondition node are evaluated and combined using an AND condition if not otherwise stated.
Method Summary
  __init__(self, parent, type, prefixList)
  asSQL(self, paramDict)
Return the condition tree as SQL string in python-format using placeholders and a given parameter dictionary.
  buildFromList(self, prefixList)
This function creates a (partial) condition tree from a prefix notation list.
  evaluate(self, lookup)
Evaluate a condition tree using a given lookup dictionary for field- and parameter-values.
  prefixNotation(self)
This function returns the prefix notation of an element and all it's children.
  validate(self)
This function calls validate () on all it's children.
    Inherited from GObj
  __getitem__(self, key)
  __setitem__(self, key, value)
  _dumpXML_(self, lookupDict, treeDump, gap, xmlnamespaces, textEncoding, stripPrefixes, escape)
Dumps an XML representation of the object
  buildAndInitObject(self, **params)
This is a convenience function for applications NOT using GParser to load an object tree.
  buildObject(self, **params)
A convenience function for applications NOT using GParser to load an object tree.
string getXmlTag(self, stripPrefixes)
Returns the xml tag to be used to represent the object.
  iterator(self, test, types, includeSelf)
Return a python iterator of child objects.
  maxInits(self)
maxInits returns the maximum size of all the _inits list from this object or it's children
  phaseInit(self, iterations)
Starts GNUe's phased initialization system from this object down.
  showTree(self, indent)
A recusive function to print an indented text representation of the GObj tree from this object down.
  walk(self, function, *args, **parms)
Function that recursively walks down through a tree of ParserObj instances and applies a function to them.
    Inherited from GTriggerCore
  __repr__(self)
  create_namespace_object(self, global_namespace, namespace_name)
Construct a namespace object tree from an XML (definitions.GObjects.GObj) object tree.
  get_namespace_object(self)
Return the namespace object that mirrors this object in the action/trigger namespace.
    Inherited from ParserObj
  _diffActionWalker_(self, obj, action)
Set the action attribute of a given object to the specified action.
  _getAsContents_(self)
Get the contents of this object.
  _id_(self, maxIdLength)
Return a compareable and identifying id of an object within a tree.
  _set_initial_attributes_(self, attributes)
Set attributes loaded by GParser.
  addChild(self, child)
Add an object to the list of children
  assign(self, source, recursive)
Assign all attributes from a given object to this one.
  diff(self, goal, maxIdLength)
Build an object tree representing the difference between two object trees.
  dumpXML(self, lookupDict, treeDump, gap, xmlnamespaces, textEncoding, stripPrefixes, escape)
Return a XML representation of the object.
  findChildNamed(self, name, childType)
Moves downward though the children of an object till it finds the child with the specified name.
  findChildOfType(self, childType, includeSelf, allowAllChildren)
Moves downward through the children of an object till it finds the child of the specified type.
  findChildrenOfType(self, childType, includeSelf, allowAllChildren)
Find all children of a specific type.
  findParentOfType(self, parentType, includeSelf)
Moves upward though the parents of an object till it finds the parent of the specified type.
  getChildrenAsContent(self)
Returns the content of any GContent objects that are children of this object.
  getDescription(self)
Return a useful description of the object.
any getParent(self)
Returns the immediate parent of an object instance in a GObj tree.
  merge(self, other, maxIdLength, overwrite)
Merge another object tree into this tree.
  setParent(self, newParent)
Set the immediate parent of an object instance in a GObj tree
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
Return hash(x)...
  __new__(T, S, ...)
Return a new object with type S, a subtype of T...
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
Return str(x)...

Instance Variable Summary
  _maxChildren_: if not None specifies the maximum number of children allowed for a condition element.
  _operator_: unicode string defining the operator used for SQL transformation of a condition element.

Method Details

__init__(self, parent=None, type='GCCondition', prefixList=None)
(Constructor)

Parameters:
parent - Parent instance in the GObj tree owning this instance
type - type of this instance (usually 'GCCondition')
prefixList - a condition in prefix notation; if this sequence is not None, a condition tree according to this sequence will be built. This instance is the root element of the newly created condition tree.
Overrides:
gnue.common.definitions.GObjects.GObj.__init__

asSQL(self, paramDict)

Return the condition tree as SQL string in python-format using placeholders and a given parameter dictionary.

Example:
 condition = ['eq', ['field', 'foobar'], ['const', 'barbaz']]
 result = condition.asSQL (pDict)

 result = 'foobar = %(p0)s'
 pDcit  = {'p0': 'barbaz'}
Parameters:
paramDict - dictionary with all parameter values. this dictionary will be populated with all placeholders used in the SQL string.
Returns:
SQL string representing the current condition

buildFromList(self, prefixList)

This function creates a (partial) condition tree from a prefix notation list.
Parameters:
prefixList - condition element sequence in prefix notation
Returns:
GCondition tree

evaluate(self, lookup)

Evaluate a condition tree using a given lookup dictionary for field- and parameter-values. Evaluation stops on the first False result.
Parameters:
lookup - dictionary used for lookups of field- and parameter-values.
Returns:
True or False
Raises:
ArgumentCountError - if the number of child elements somewhere in the tree is incorrect.
MissingFieldError - if not all fields appearing in the condition tree are assigned a value in the lookup dictionary.
ConversionRuleError - if any operation is given two incompatible arguments.
ConversionError - if the type conversion needed to make arguments of an operation comatible fails.

prefixNotation(self)

This function returns the prefix notation of an element and all it's children.

validate(self)

This function calls validate () on all it's children. Descendants might override this function to do integrity checks and things like that.
Raises:
ArgumentCountError - if the number of child elements somewhere in the tree is incorrect.

Instance Variable Details

_maxChildren_

if not None specifies the maximum number of children allowed for a condition element.

_operator_

unicode string defining the operator used for SQL transformation of a condition element.


GNUe Home

Public API

Developer's Corner