dspam.ctx Class Reference

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

List of all members.

Public Member Functions

def __init__
 Initialize dspam context.
def process
 Calls dspam_process(DSPAM_CTX ctx, const char *msg).
def addattribute
 Add configuration attribute to context.
def clearattributes
 Clear configuration attributes from this context.
def attach
 Attaches storage driver to context.
def set_signature
 Store a signature using the attached storage driver.
def get_signature
 Retrieve a signature stored using the attached storage driver.
def delete_signature
 Delete a signature stored using the attached storage driver.
def verify_signature
 Verify a signature stored using the attached storage driver.
def detach
 Detaches storage driver from context.
def tokenize
 Tokenize the header and body of a message, and return a dictionary of token,freq tuples by hash.
def destroy
 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.
 training_mode
 Training mode.
 totals
 Totals.
 probability
 Probability.
 factors
 Factors.

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.


Member Function Documentation

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

Initialize dspam context.

Parameters:
username dspam account the account applies to
mode dspam processing mode: DSM_*
flags dspam processing flags: DSF_*
group dspam group
home dspam home dir, libdspam compiled default if none. On RedHat/Fedora, this is /var/lib/dspam.
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:
key str key
val str value
def dspam.ctx.attach (   self,
  dbh = None 
)

Attaches storage driver to context.

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

Parameters:
dbh a storage handle obtained from the driver ctx in a driver specific way so it can be reused, or None
def dspam.ctx.clearattributes (   self  ) 

Clear configuration attributes from this context.

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:
tag unique tag assigned to the signature
def dspam.ctx.destroy (   self  ) 

Destroy context, releasing all resources.

def dspam.ctx.detach (   self  ) 

Detaches storage driver from context.

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:
tag unique tag assigned to the signature
Returns:
the tag retreived
def dspam.ctx.process (   self,
  msg,
  sig = None 
)

Calls dspam_process(DSPAM_CTX ctx, const char *msg).

Parameters:
msg the email message to process
sig a signature obtained from self.signature, or None
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:
tag unique tag assigned to the signature
sig Binary signature obtained from self.signature
def dspam.ctx.tokenize (   self,
  header,
  body 
)

Tokenize the header and body of a message, and return a dictionary of token,freq tuples by hash.

def dspam.ctx.verify_signature (   self,
  tag 
)

Verify a signature stored using the attached storage driver.

Use verify_signature to check first.

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

Member Data Documentation

Classification algorithms to employ.

Use any combination of DSA_* and DSP_* flags.

Callers classification.

Factors.

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

Probability.

The probability that the message is spam according to libdspam.

Result of DSPAM classification.

Source of callers classification.

Tokenizer algorithm.

Totals.

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

Training mode.

Use one of DST_* flags.


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

Generated on 15 Feb 2015 for pydspam by  doxygen 1.6.1