From 83a1762515d3e34400beaad3979006f0d7677a59 Mon Sep 17 00:00:00 2001
From: Stuart Gathman <stuart@gathman.org>
Date: Sat, 5 Nov 2011 15:51:03 +0000
Subject: [PATCH] New example

---
 Milter/__init__.py | 10 ++++++++--
 milter-nomix.py    | 19 +++++--------------
 milter-template.py |  3 +--
 mime.py            |  6 ++++--
 4 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/Milter/__init__.py b/Milter/__init__.py
index 8abffd6..2df9268 100755
--- a/Milter/__init__.py
+++ b/Milter/__init__.py
@@ -310,7 +310,7 @@ class Base(object):
   ## Called when the connection is closed.
   def close(self): return CONTINUE
 
-  ## Return mask of SMFIP_N.. protocol option bits to clear for this class
+  ## Return mask of SMFIP_N* protocol option bits to clear for this class
   # The @@nocallback and @@noreply decorators set the
   # <code>milter_protocol</code> function attribute to the protocol mask bit to
   # pass to libmilter, causing that callback or its reply to be skipped.
@@ -336,7 +336,10 @@ class Base(object):
     
   ## Negotiate milter protocol options.  Called by the
   # <a href="https://www.milter.org/developers/api/xxfi_negotiate">
-  # xffi_negotiate</a> callback.
+  # xffi_negotiate</a> callback.  This is an advanced callback,
+  # do not override unless you know what you are doing.  Most
+  # negotiation can be done simply by using the supplied 
+  # class and function decorators.
   # Options are passed as 
   # a list of 4 32-bit ints which can be modified and are passed
   # back to libmilter on return.
@@ -363,6 +366,8 @@ class Base(object):
   ## Return the value of an MTA macro.  Sendmail macro names
   # are either single chars (e.g. "j") or multiple chars enclosed
   # in braces (e.g. "{auth_type}").  Macro names are MTA dependent.
+  # See <a href="https://www.milter.org/developers/api/smfi_getsymval">
+  # smfi_getsymval</a> for default sendmail macros.
   # @param sym the macro name
   def getsymval(self,sym):
     return self._ctx.getsymval(sym)
@@ -714,4 +719,5 @@ for priv in ('os','milter','thread','factory','_seq','_seq_lock','__version__'):
 __all__ = __all__.keys()
 
 ## @example milter-template.py
+## @example milter-nomix.py
 #
diff --git a/milter-nomix.py b/milter-nomix.py
index b7899a6..a6686ba 100644
--- a/milter-nomix.py
+++ b/milter-nomix.py
@@ -1,12 +1,7 @@
-## To roll your own milter, create a class that extends Milter.  
-#  See the pymilter project at http://bmsi.com/python/milter.html
-#  based on Sendmail's milter API http://www.milter.org/milter_api/api.html
+## A very simple milter to prevent mixing of internal and external mail.  
+# Internal is defined as using one of a list of internal top level domains.
 #  This code is open-source on the same terms as Python.
 
-## Milter calls methods of your class at milter events.
-## Return REJECT,TEMPFAIL,ACCEPT to short circuit processing for a message.
-## You can also add/del recipients, replacebody, add/del headers, etc.
-
 import Milter
 import time
 import sys
@@ -14,15 +9,11 @@ from Milter.utils import parse_addr
 
 internal_tlds = ["corp", "personal"]
 
-# Determine if a hostname is internal or not. True if internal,
-# False otherwise
+## Determine if a hostname is internal or not. 
+# True if internal, False otherwise
 def is_internal(hostname):
     components = hostname.split(".")
-
-    if components.pop() in internal_tlds:
-        return True
-    else:
-        return False
+    return components.pop() in internal_tlds:
 
 # Determine if internal and external hosts are mixed based on a list
 # of hostnames
diff --git a/milter-template.py b/milter-template.py
index ee72380..77f2c40 100644
--- a/milter-template.py
+++ b/milter-template.py
@@ -79,7 +79,7 @@ class myMilter(Milter.Base):
 
   ##  def envrcpt(self, to, *str):
   @Milter.noreply
-  def envrcpt(self, recipient, *str):
+  def envrcpt(self, to, *str):
     rcptinfo = to,Milter.dictfromlist(str)
     self.R.append(rcptinfo)
     
@@ -110,7 +110,6 @@ class myMilter(Milter.Base):
     self.addrcpt('<%s>' % 'spy@example.com')
     return Milter.ACCEPT
 
-
   def close(self):
     # always called, even when abort is called.  Clean up
     # any external resources here.
diff --git a/mime.py b/mime.py
index f35bb69..dd01e9e 100644
--- a/mime.py
+++ b/mime.py
@@ -1,4 +1,7 @@
 # $Log$
+# Revision 1.7  2009/06/13 21:15:12  customdesigned
+# Doxygen updates.
+#
 # Revision 1.6  2009/06/09 03:13:13  customdesigned
 # More doxygen docs.
 #
@@ -165,15 +168,14 @@ class MimeMessage(Message):
   """
   def __init__(self,fp=None,seekable=1):
     Message.__init__(self)
-    self.headerchange = None
     self.submsg = None
     self.modified = False
-
   ## @var headerchange
   # Provide a headerchange event for integration with Milter.
   #   The headerchange attribute can be assigned a function to be called when
   #   changing headers.  The signature is:
   #   headerchange(msg,name,value) -> None
+    self.headerchange = None
 
   def get_param(self, param, failobj=None, header='content-type', unquote=True):
     val = Message.get_param(self,param,failobj,header,unquote)
-- 
GitLab