chapps.sqla_adapter module

Policy Configuration Adapters based on SQLAlchemy

Policy-configuration source data adapters.

These adapter classes have been adjusted from their original form to use SQLAlchemy.

class chapps.sqla_adapter.SQLAPolicyConfigAdapter[source]

Bases: object

Base class for policy config access using SQLAlchemy

__init__(*, cfg=None, db_host=None, db_port=None, db_name=None, db_user=None, db_pass=None, autocommit=True)[source]
Parameters
  • db_host (str) – the hostname or IP address of the database server

  • db_port (int) – the port number of the database server

  • db_name (str) – the name of the database

  • db_user (str) – the username for login

  • db_pass (str) – the password for the user

  • autocommit (bool) – defaults to True

  • cfg (Optional[chapps.config.CHAPPSConfig]) –

finalize()[source]

Do nothing. A no-op to maintain backward compatibility.

class chapps.sqla_adapter.SQLAQuotaAdapter[source]

Bases: chapps.sqla_adapter.SQLAPolicyConfigAdapter

An adapter for obtaining quota policy data from MariaDB using SQLAlchemy

quota_for_user(user)[source]

Return the quota amount for an user account

Parameters

user (str) – the user’s name

Return type

Optional[int]

class chapps.sqla_adapter.SQLASenderDomainAuthAdapter[source]

Bases: chapps.sqla_adapter.SQLAPolicyConfigAdapter

An adapter to obtain sender domain authorization data from MariaDB

check_domain_for_user(user, domain)[source]

Returns True if the user is authorized to send for this domain

Parameters
  • user (str) – name of user

  • domain (str) – name of domain

Return type

bool

check_email_for_user(user, email)[source]

Returns True if the user is authorized to send as this email

Parameters
  • user (str) – name of user

  • email (str) – email address

Return type

bool

class chapps.sqla_adapter.SQLAInboundFlagsAdapter[source]

Bases: chapps.sqla_adapter.SQLAPolicyConfigAdapter

do_greylisting_on(domain)[source]

Returns true if the domain enforces greylisting, otherwise False

Parameters

domain (str) – full domain part

Raises

NoSuchDomainException – if the domain doesn’t exist

check_spf_on(domain)[source]

Returns true if the domain enforces SPF policies, else False

Parameters

domain (str) – full domain part

Raises

NoSuchDomainException – if the domain doesn’t exist