Wp.DynamicRules¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
Fields¶
- Inherited:
Class Details¶
- class Wp.DynamicRules(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Wp.DynamicRulesevaluates dynamic rules against added subject objects and triggers the apply-actions and revert-actions signals whenever a rule’s actions should be applied or reverted respectively. Rules can be added either from JSON withWp.DynamicRules.add_json_rule() or programmatically withWp.DynamicRules.add_condition_rule() andWp.DynamicRules.add_condition_rule_closure(). JSON rules may carry an optional conditions block in addition to the standard matches and actions blocks. A condition block lists external objects that must exist for the rule to be satisfied. Rule JSON format: Entries in conditions are AND: all must be satisfied. Entries in a condition’s matches are OR: any one matching object satisfies it. Rules without a conditions block are always considered satisfied. UseWp.Object.activate() withWp.DynamicRulesFeatures.LOADEDto activate. CallWp.DynamicRules.add_object() to register subject objects to evaluate.- classmethod new(core)¶
- Parameters:
- Returns:
the new
Wp.DynamicRules- Return type:
Creates a new
Wp.DynamicRulesobject.Call
Wp.Object.activate() withWp.DynamicRulesFeatures.LOADEDto start watching objects. UseWp.DynamicRules.add_json_rule() orWp.DynamicRules.add_condition_rule() to add rules to the object.Added in version 0.5.16.
- add_condition_rule(matches, actions, callback, *user_data)¶
- Parameters:
matches (
Wp.ObjectInterest) – object interest that matches subject objectsactions (
Wp.SpaJson) – action object emitted by the rulecallback (
Wp.DynamicRulesConditionCallback) – callback to evaluate the condition
- Returns:
the added rule ID, or SPA_ID_INVALID on error
- Return type:
Adds a dynamic rule with a condition callback.
The provided matches interest determines if a subject object is matched. The provided actions object is emitted when the rule is satisfied. The provided callback is evaluated as an additional condition.
Added in version 0.5.16.
- add_condition_rule_closure(matches, actions, closure)¶
- Parameters:
matches (
Wp.ObjectInterest) – object interest that matches subject objectsactions (
Wp.SpaJson) – action object emitted by the ruleclosure (
GObject.Closure) – closure to evaluate the condition
- Returns:
the added rule ID, or SPA_ID_INVALID on error
- Return type:
Adds a dynamic rule with a condition closure.
The provided matches interest determines if a subject object is matched. The provided actions object is emitted when the rule is satisfied. The provided closure is evaluated as an additional condition.
Added in version 0.5.16.
- add_json_rule(json_rule)¶
- Parameters:
json_rule (
Wp.SpaJson) – JSON object defining the rule- Returns:
the added rule ID, or SPA_ID_INVALID on error
- Return type:
Adds a dynamic rule from a JSON object.
The JSON object must have “matches” and “actions” properties. It may optionally have a “conditions” array property.
Added in version 0.5.16.
- add_object(object)¶
- Parameters:
object (
Wp.GlobalProxy) – the subject object to add
Adds an object to be evaluated against the rules.
If already loaded, the object is evaluated immediately and apply-actions or revert-actions signals are emitted as appropriate.
Added in version 0.5.16.
- remove_object(object)¶
- Parameters:
object (
Wp.GlobalProxy) – the subject object to remove
Removes a previously added object.
Added in version 0.5.16.
- remove_rule(rule_id)¶
- Parameters:
rule_id (
int) – the rule ID returned byWp.DynamicRules.add_condition_rule() orWp.DynamicRules.add_json_rule()
Removes a previously added dynamic rule.
Added in version 0.5.16.
Signal Details¶
- Wp.DynamicRules.signals.apply_actions(dynamic_rules, object, p0, p1, p2)¶
- Signal Name:
apply-actions- Flags:
- Parameters:
dynamic_rules (
Wp.DynamicRules) – The object which received the signalobject (
int)p0 (
str)p1 (
Wp.SpaJson)p2 (
Wp.GlobalProxy)
- Wp.DynamicRules.signals.revert_actions(dynamic_rules, object, p0, p1, p2)¶
- Signal Name:
revert-actions- Flags:
- Parameters:
dynamic_rules (
Wp.DynamicRules) – The object which received the signalobject (
int)p0 (
str)p1 (
Wp.SpaJson)p2 (
Wp.GlobalProxy)