[Mailman-Developers] Bug#57223: mailman: gate_news problems (fwd)
Jim Tittsler
jwt@dskk.co.jp
Tue, 8 Feb 2000 11:47:06 +0900
--FCuugMFkClbJLl1L
Content-Type: text/plain; charset=us-ascii
On Mon, Feb 07, 2000 at 07:17:13PM +0100, Thomas Wouters wrote:
> On Mon, Feb 07, 2000 at 12:53:17PM -0500, Barry A. Warsaw wrote:
>
> > I'm cutting and pasting a message that originated on the mailman-users
> > mailing list. I think this message is fairly self-explanatory. Can
> > other NNTP experts look this over and see if it makes sense? I'll
> > apply it if there are no objections.
> > Note: the bare except is bothersome.
I confess I wasn't sure if a news server that didn't recognize the 'mode
reader' could be counted on to return a 500 series error. It seemed
logical, but I couldn't be sure. (All of the servers I have access
to accept the 'mode reader'.)
> Note, though, that i've already posted a small patch to mailman to fix this.
> Since the 'group' command is executed by gate_news, which doesn't need
> authentication, it's easy enough to try the group, and set the connection to
> readermode if it fails.
I dislike your proposed solution for two reasons:
1. It uses the nntplib's shortcmd outside of nntplib, even though it is
documented as "internal".
2. It doesn't work when you *do* need authentication. The group command
will claim 'No such group' for groups that are hidden by authentication.
(One of my mailman run on such a machine.) You need to do the 'mode
reader' before authenticating.
I still think it better to change nntplib.
> Also note that I've already sent a patch to patches@python.org ;) with a
> pointer to the mailman-users discussion in question.
>
> http://www.python.org/pipermail/patches/2000-February/000015.html
>
> My patch uses an extra argument to NNTP.__init__, and avoids the bare
> except. To get the same behaviour as the patch below, sending 'mode
> reader' by default, the default value of readermode can be set to 1. I'm not
> sure if that's a wise thing, however, as some users of nntplib.NNTP might
> depend on the connection being able to do things that you cant do in
> readermode.
I sent a similar nntplib patch to mailman-users last week, although I
defaulted to the current behavior and required the additional argument
(or a user specified for authentication) to get the "newsreader" behavior.
http://www.python.org/pipermail/mailman-users/2000-February/003935.html
Jim
--FCuugMFkClbJLl1L
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="nntplib.diff"
--- /home/jwt/nntplib.py.orig Sat Sep 18 09:16:08 1999
+++ nntplib.py Sat Sep 18 11:39:00 1999
@@ -61,17 +61,24 @@
# Initialize an instance. Arguments:
# - host: hostname to connect to
# - port: port to connect to (default the standard NNTP port)
+ # - mode: if not None (or user is specified), issue 'mode reader'
- def __init__(self, host, port = NNTP_PORT, user=None, password=None):
+ def __init__(self, host, port = NNTP_PORT, user=None, password=None,
+ mode=None):
self.host = host
self.port = port
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect(self.host, self.port)
self.file = self.sock.makefile('rb')
self.debugging = 0
self.welcome = self.getresp()
+ if user or mode:
+ try:
+ self.welcome = self.shortcmd('mode reader')
+ except:
+ pass
if user:
resp = self.shortcmd('authinfo user '+user)
if resp[:3] == '381':
if not password:
@@ -466,9 +473,9 @@
# Minimal test function
def _test():
- s = NNTP('news')
+ s = NNTP('news', mode='reader')
resp, count, first, last, name = s.group('comp.lang.python')
print resp
print 'Group', name, 'has', count, 'articles, range', first, 'to', last
resp, subs = s.xhdr('subject', first + '-' + last)
--FCuugMFkClbJLl1L--