Wp.DynamicRules

g GObject.Object GObject.Object Wp.Object Wp.Object GObject.Object->Wp.Object Wp.DynamicRules Wp.DynamicRules Wp.Object->Wp.DynamicRules

Subclasses:

None

Methods

Inherited:

Wp.Object (12), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (core)

add_condition_rule (matches, actions, callback, *user_data)

add_condition_rule_closure (matches, actions, closure)

add_json_rule (json_rule)

add_object (object)

remove_object (object)

remove_rule (rule_id)

Virtual Methods

Inherited:

Wp.Object (4), GObject.Object (7)

Properties

Inherited:

Wp.Object (4)

Signals

Inherited:

GObject.Object (1)

Name

Short Description

apply-actions

revert-actions

Fields

Inherited:

GObject.Object (1)

Class Details

class Wp.DynamicRules(**kwargs)
Bases:

Wp.Object

Abstract:

No

Structure:

Wp.DynamicRulesClass

Wp.DynamicRules evaluates 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 with Wp.DynamicRules.add_json_rule() or programmatically with Wp.DynamicRules.add_condition_rule() and Wp.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. Use Wp.Object.activate() with Wp.DynamicRulesFeatures.LOADED to activate. Call Wp.DynamicRules.add_object() to register subject objects to evaluate.

classmethod new(core)
Parameters:

core (Wp.Core) – the Wp.Core

Returns:

the new Wp.DynamicRules

Return type:

Wp.DynamicRules

Creates a new Wp.DynamicRules object.

Call Wp.Object.activate() with Wp.DynamicRulesFeatures.LOADED to start watching objects. Use Wp.DynamicRules.add_json_rule() or Wp.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:
Returns:

the added rule ID, or SPA_ID_INVALID on error

Return type:

int

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:
Returns:

the added rule ID, or SPA_ID_INVALID on error

Return type:

int

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:

int

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 by Wp.DynamicRules.add_condition_rule() or Wp.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:

RUN_LAST

Parameters:
Wp.DynamicRules.signals.revert_actions(dynamic_rules, object, p0, p1, p2)
Signal Name:

revert-actions

Flags:

RUN_LAST

Parameters: