pydspam  1.4
Public Member Functions | Public Attributes | List of all members
dspam.ctx Class Reference

Hold context for a DSPAM message operation Each context creates a new DSPAM_CTX struct within libdspam. More...

Inheritance diagram for dspam.ctx:

Public Member Functions

def __init__ (self, username, mode, flags=0, group=None, home=None)
 Initialize dspam context. More...
 
def process (self, msg, sig=None)
 Calls dspam_process(DSPAM_CTX ctx, const char *msg) More...
 
def addattribute (self, key, val)
 Add configuration attribute to context. More...
 
def clearattributes (self)
 Clear configuration attributes from this context.
 
def attach (self, dbh=None)
 Attaches storage driver to context. More...
 
def set_signature (self, tag, sig)
 Store a signature using the attached storage driver. More...
 
def get_signature (self, tag)
 Retrieve a signature stored using the attached storage driver. More...
 
def delete_signature (self, tag)
 Delete a signature stored using the attached storage driver. More...
 
def verify_signature (self, tag)
 Verify a signature stored using the attached storage driver. More...
 
def detach (self)
 Detaches storage driver from context. More...
 
def tokenize (self, header, body)
 Tokenize the header and body of a message, and return a dictionary of token,freq tuples by hash.
 
def destroy (self)
 Destroy context, releasing all resources.
 

Public Attributes

 result
 Result of DSPAM classification.
 
 classification
 Callers classification.
 
 source
 Source of callers classification.
 
 tokenizer
 Tokenizer algorithm.
 
 algorithms
 Classification algorithms to employ. More...
 
 training_mode
 Training mode. More...
 
 totals
 Totals. More...
 
 probability
 Probability. More...
 
 factors
 Factors. More...
 

Detailed Description

Hold context for a DSPAM message operation Each context creates a new DSPAM_CTX struct within libdspam.

The dspam module in turn creates a ctx object.

Most application interaction with libdspam takes places via the ctx object for the connection.

Constructor & Destructor Documentation

◆ __init__()

def dspam.ctx.__init__ (   self,
  username,
  mode,
  flags = 0,
  group = None,
  home = None 
)

Initialize dspam context.


Parameters
usernamedspam account the account applies to
modedspam processing mode: DSM_*
flagsdspam processing flags: DSF_*
groupdspam group
homedspam home dir, libdspam compiled default if none. On RedHat/Fedora, this is /var/lib/dspam.

Member Function Documentation

◆ addattribute()

def dspam.ctx.addattribute (   self,
  key,
  val 
)

Add configuration attribute to context.

Context configuration controls the tokenizer, storage driver, and other aspects of DSPAM for this context.

Parameters
keystr key
valstr value

◆ attach()

def dspam.ctx.attach (   self,
  dbh = None 
)

Attaches storage driver to context.

Driver specific context configuration should be done before attaching the driver.

Parameters
dbha storage handle obtained from the driver ctx in a driver specific way so it can be reused, or None

◆ delete_signature()

def dspam.ctx.delete_signature (   self,
  tag 
)

Delete a signature stored using the attached storage driver.


Throws an exception if the tag is not present.

Parameters
tagstr - unique tag assigned to the signature

◆ detach()

def dspam.ctx.detach (   self)

Detaches storage driver from context.


◆ get_signature()

def dspam.ctx.get_signature (   self,
  tag 
)

Retrieve a signature stored using the attached storage driver.


Throws an exception if the tag is not present. Use verify_signature to check first.

Parameters
tagstr - unique tag assigned to the signature
Returns
the tag str retrieved

◆ process()

def dspam.ctx.process (   self,
  msg,
  sig = None 
)

Calls dspam_process(DSPAM_CTX ctx, const char *msg)

Parameters
msgthe email message to process
siga signature obtained from self.signature, or None

◆ set_signature()

def dspam.ctx.set_signature (   self,
  tag,
  sig 
)

Store a signature using the attached storage driver.

The tag should be suitable for a filename.

Parameters
tagstr - unique tag assigned to the signature
sigBinary signature obtained from self.signature

◆ verify_signature()

def dspam.ctx.verify_signature (   self,
  tag 
)

Verify a signature stored using the attached storage driver.


Use verify_signature to check first.

Parameters
tagstr - unique tag assigned to the signature
Returns
True if the tag still exists in storage

Member Data Documentation

◆ algorithms

dspam.ctx.algorithms

Classification algorithms to employ.

Use any combination of DSA_* and DSP_* flags.

◆ factors

dspam.ctx.factors

Factors.

A list of token_name,weight tuples. These are the factors used by dspam to compute the probability.

◆ probability

dspam.ctx.probability

Probability.

The probability that the message is spam according to libdspam.

◆ totals

dspam.ctx.totals

Totals.

A tuple of 8 ints: (spam_learned, innocent_learned, spam_misclassified, innocent_misclassified, spam_corpusfed, innocent_corpusfed, spam_classified, innocent_classified)

◆ training_mode

dspam.ctx.training_mode

Training mode.

Use one of DST_* flags.


The documentation for this class was generated from the following file: