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

Module gnue.common.datasources.GConditions

Classes for the condition object tree.
Classes
GBinaryConditionElement Abstract base class for all binary condition elements.
GCadd Numeric addition.
GCand Logical AND.
GCbetween Test for SQL BETWEEN.
GCConst Constant value of a specific type.
GCdiv Numeric division.
GCeq Test for equality.
GCexist Test if a record fulfilling a given condition exists in another table.
GCField Field value from a database table.
GCge Test for greater or equal.
GCgt Test for greater than.
GCle Test for lower or equal.
GClike Test for SQL LIKE.
GClower String conversion to lowercase.
GClt Test for lower than.
GCmul Numeric multiplication.
GCne Test for inequality.
GCnegate Numeric negation.
GCnot Logical NOT.
GCnotbetween Test for SQL NOT BETWEEN.
GCnotlike Test for SQL NOT LIKE.
GCnotnull Test for SQL IS NOT NULL
GCnull Test for SQL IS NULL
GCondition A GCondition instance is allways the root node of a condition tree.
GConditionElement Abstract base class for all condition elements.
GCor Logical OR.
GCParam Abstract class for parameters.
GCsub Numeric subtraction.
GCupper String conversion to uppercase.
GUnaryConditionElement Abstract base class for all unary condition elements.

Exceptions
ArgumentCountError Number of child elements is incorrect.
ConditionError Abstract base class for all errors in condition definitions.
ConversionError Cannot convert a value.
ConversionRuleError Cannot convert both data types into a common compatible type.
MalformedConditionTreeError Abstract base class for all errors in the structure of the condition tree.
MissingFieldError Cannot find field value on attempt to evaluate a condition.
UnificationError Abstract base class for all errors on unifying different data types.

Function Summary
  buildCondition(condition, comparison, logic)
Create a condition tree either from a sequence in prefix notation or a dictionary.
  buildConditionFromDict(dictionary, comparison, logic)
This function creates a new condition tree using the given comparison as operation between keys and values and a given logic as concatenation for all keys.
  buildConditionFromPrefix(prefixList)
This function creates a new condition tree from the given element sequence, which must be in prefix notation.
  combineConditions(cond1, cond2)
Combine two conditions using an AND operator.
  getXMLelements(updates)
  unify(values)
Convert all items in a given sequence to the same types.

Function Details

buildCondition(condition, comparison=<class 'gnue.common.datasources.GConditions.GCeq'>, logic=<class 'gnue.common.datasources.GConditions.GCand'>)

Create a condition tree either from a sequence in prefix notation or a dictionary. In the latter case an optional comparison- and logic-operator class might be specified.
Parameters:
condition - sequence in prefix notation or a dictionary with the condition to be converted
comparison - (operator) class used to compare keys and values
logic - (operator) class used to concatenate multiple comparisons
Returns:
GCondition tree

buildConditionFromDict(dictionary, comparison=<class 'gnue.common.datasources.GConditions.GCeq'>, logic=<class 'gnue.common.datasources.GConditions.GCand'>)

This function creates a new condition tree using the given comparison as operation between keys and values and a given logic as concatenation for all keys.
Parameters:
dictionary - dictionary with (key, value) pairs to convert into a condition tree
comparison - (operator) class used to compare keys and values
logic - (operator) class used to concatenate multiple comparisons
Returns:
GCondition tree

buildConditionFromPrefix(prefixList)

This function creates a new condition tree from the given element sequence, which must be in prefix notation.
Parameters:
prefixList - sequence of condition elements in prefix notation
Returns:
GCondition tree

combineConditions(cond1, cond2)

Combine two conditions using an AND operator. Both arguments can be given as condition trees (GCondition), dictionaries or prefix sequences. The resulting combination is a *new* condition tree. None of the arguments will be changed.
Parameters:
cond1 - condition-tree, -dictionary or -sequence (prefix list)
cond2 - condition-tree, -dictionary or -sequence (prefix list)
Returns:
new GCondition instance with an AND-combination of both conditions

getXMLelements(updates={})

unify(values)

Convert all items in a given sequence to the same types.
Parameters:
values - sequence of items to be converted to a common type
Returns:
sequence of converted items having all the same datatype.


GNUe Home

Public API

Developer's Corner