configurationengine/doc/rule.rst
author terytkon
Thu, 11 Mar 2010 17:04:37 +0200
changeset 0 2e8eeb919028
permissions -rw-r--r--
Adding EPL version of configurationengine.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     1
Rule
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     2
====
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     3
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     4
	A Configuration can contain rule's, which can be aplied to the :class:`~cone.public.api.Configuration` 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     5
	:class:`~cone.public.api.Feature`'s. In ConE a single rule will create an instance of :class:`~cone.public.plugin.Relation`. 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     6
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     7
	The textual format of a rules is always of form:
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     8
	::
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
     9
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    10
	  <left side> relation_name <right side>.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    11
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    12
The rule dialect
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    13
----------------
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    14
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    15
	The features are accessed in the left and right side of the rule with the default :class:`~cone.public.api.View` of the :class:`~cone.public.api.Configuration`. 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    16
	Basically ConE will get the default_view and use the :class:`~cone.public.api.ObjectContainer` member access to retrieve the feature.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    17
	There are few special characters that are converted to function calls in the rule transformation.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    18
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    19
	* ``*`` => refers to all immediate childer of this node, which is transformed to method call :meth:`cone.public.api.ObjectContainer.__objects__`
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    20
	* ``**`` => refers to all childer of this node, which is transformed to method call :meth:`cone.public.api.ObjectContainer.__traverse__`
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    21
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    22
	Both sides of the rule are something that the :class:`~cone.public.plugin.Relation` will somehow evaluate. How the left 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    23
	side and right side are evaluated, is basically specific to the implementation of the :meth:`~cone.public.plugin.Relation.execute` 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    24
	method of the :class:`~cone.public.plugin.Relation`. However certain basic evaluation rules apply to all :class:`~cone.public.plugin.Relation` objects.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    25
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    26
	When a feature is referred, ConE will try to return the value of the feature. 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    27
	Then the Relation tries to evaluate if the given feature is bound and evaluates as True.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    28
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    29
	So for example referring to a feature.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    30
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    31
	``group.fea1`` is the same as writing ``group.fea1==True`` for a boolean feature.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    32
	``group.intfea1`` is the same as writing ``group.fea1!=0`` for a integer feature.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    33
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    34
	If a feature is unbound, trying to access its value will raise UnboundError. 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    35
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    36
Boolean logic in rules
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    37
----------------------
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    38
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    39
		Both left and right side of the rule can contain normal boolean algebra that is utilized in the evaluation. This uses 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    40
		default python syntax for boolean logic, with keywords *and*, *or*, *not*.
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    41
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    42
Example of boolean logic
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    43
^^^^^^^^^^^^^^^^^^^^^^^^  
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    44
::
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    45
	a.b and c.d=10 depends (not a.b.x=10 or a.b.x=0)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    46
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    47
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    48
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    49
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    50
Rules with different multiplicity
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    51
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    52
	The above mechanism enables that the rules can define relations with different multiplicity. 
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    53
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    54
	* one-to-one
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    55
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    56
		* e.g. A depends B
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    57
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    58
	* one-to-many
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    59
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    60
		* e.g. A depends B.*, which is basically the same as wrinting A depends (B.child1 and B.child2 and ..)
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    61
		* e.g. A depends B and C
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    62
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    63
	* many-to-one
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    64
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    65
		* e.g. A.* depends B
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    66
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    67
	* many-to-many
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    68
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    69
		* e.g. A.* depends B.*
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    70
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    71
Examples
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    72
--------
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    73
	
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    74
	* A.B.C requires A.B.D
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    75
	* fea.group.* requires fea.group
2e8eeb919028 Adding EPL version of configurationengine.
terytkon
parents:
diff changeset
    76
	* wlan.setting maps voip.setting=10