Rules

The rule module defines two classes, Rule and RuleDict, derived from DbSchemaObject and DbObjectDict, respectively.

Rule

Rule is derived from DbSchemaObject and represents a PostgreSQL rewrite rule.

class pyrseas.dbobject.rule.Rule(name, schema, table, description, event, instead=False, actions=None, condition=None, definition=None, oid=None)

A rewrite rule definition

static Rule.from_map(name, table, inobj)

Initialize a Rule instance from a YAML map

Parameters:
  • name – rule name
  • table – map of the table associated with the rule
  • inobj – YAML map of the rule
Returns:

Rule instance

Rule.identifier()

Return a full identifier for a rule object

Returns:string
Rule.to_map(db)

Convert rule to a YAML-suitable format

Returns:dictionary
Rule.create(obj, *args, **kwargs)

Return SQL statements to CREATE the rule

Returns:SQL statements

Rule Dictionary

RuleDict is derived from DbObjectDict. It is a dictionary that represents the collection of rewrite rules in a database.

class pyrseas.dbobject.rule.RuleDict(dbconn=None)

The collection of rewrite rules in a database.

RuleDict.from_map(table, inmap)

Initialize the dictionary of rules by examining the input map

Parameters:
  • table – the input YAML map of the associated table
  • inmap – the input YAML map defining the rules