[Twisted-Python] Re: nntp protocol supports moderated newsgroups?

Barry A. Warsaw barry at python.org
Sat Oct 19 12:21:43 EDT 2002

>>>>> "JC" == Jp Calderone <exarkun at twistedmatrix.com> writes:

    JC>  Hmm, twisted/news/database.py should have all the stuff it
    JC> needs already - maybe makeGroupSQL() will need to be modified
    JC> a bit so that twisted/tap/news.py can tell it which groups
    JC> should be moderated and which shouldn't.  twisted/tap/news.py
    JC> will probably have most of the action; it'll need code to let
    JC> the user specify moderated/unmoderated to mktap somehow, maybe
    JC> with another --groups parameter, or with some indicator in the
    JC> groups file.

    JC> Maybe it's time twisted.news got a *real* configuration
    JC> interface :) I'll ponder that a little (maybe something fun
    JC> with woven), and if you(/anyone else) have any ideas on this,
    JC> I'd love to hear them.

I don't really, since I'm fairly green in my Twisted use.  I will note
that the news stuff seems a little more difficult to use than when I
last looked at it (Twisted 0.19 I think).  I'm using Twisted from cvs
now, so it's possible this stuff is just in flux.


- What is the --servers switch for?  I couldn't actually find where
  that was used in tap/news.py but it seemed required, so I fed it

- I understand why "mktap news" requires an extra argument now, but it
  would be nice if either the pickle or sql command were defaulted.  I
  don't think I needed to specify "mktap news pickle" last time.  Hmm,
  maybe if --file is given you can default to pickle?

- I noticed some bugs in the code, a few of which I fixed, but some I
  didn't.  I ran the server w/ twistd -n and watched the output.  I
  got mysterious log messages such as:

19/10/2002 11:54 [*news*] Starting factory <twisted.news.news.UsenetClientFactory instance at 0x82a52d4>
19/10/2002 11:54 [*news*] Connection failed: [Failure instance: Traceback! exceptions.IOError, address not found
19/10/2002 11:54 [*news*] ]
19/10/2002 11:54 [*news*] Connection failed: [Failure instance: Traceback! exceptions.IOError, address not found
19/10/2002 11:54 [*news*] ]
19/10/2002 11:54 [*news*] Stopping factory <twisted.news.news.UsenetClientFactory instance at 0x82a52d4>
19/10/2002 11:55 [*news*] Starting factory <twisted.news.news.UsenetClientFactory instance at 0x82a52d4>

  While these repeated as long as the server was running, they didn't
  seem to affect its operation.

- In news/news.py, buildProtocol() is trying to pass self.remoteHosts
  to the self.protocol() call, but self.protocol() -- which is really
  the nntp.NNTPServer class, doesn't take two arguments.

In any event, I hacked in moderated group support by adding a
-m/--moderators flag, which takes a file containing a list of
newsgroup/moderator address pairs.  When a message is POSTed to a
group, the list of target newsgroups is checked against the
moderators.  If there is any match, and the article has no Approved
header, the article is not posted, but instead emailed to the
moderators address.  The value of the Approved header is completely
ignored -- it just has to be there.  I believe this is pretty close to
how Usenet s/w handles moderators.

A couple of kludges that should be cleaned up:

- What to do if the list of target newsgroups has more than one
  moderated newsgroup in it?  Off hand, I'm not sure what Usenet does
  in this case.

- We really need a few more config options, including the smtp host
  and port to use to send out the moderator's email, and the envelope
  sender address to use in that email.  Both are hard coded in my

- Any un-Twisted coding offenses. :)

So, in the grand tradition of scratching my own itch, but just enough
so I can sleep, here's the patch.

Oh, BTW, for someone who was completely green to the code base,
Twisted is very nicely written.  It wasn't difficult at all to drill
down to where I needed to make the changes.  JP's hints helped a lot
too.  Yay!


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: twisted.txt
Url: http://twistedmatrix.com/pipermail/twisted-python/attachments/20021019/97b86b2c/attachment.txt 

More information about the Twisted-Python mailing list