[Patches] Re: [Mailman-Developers] Bug#57223: mailman: gate_news problems (fwd)

Jim Tittsler jwt@dskk.co.jp
Wed, 9 Feb 2000 19:12:04 +0900


--yrj/dFKFPuw6o+aM
Content-Type: text/plain; charset=us-ascii

[At Barry Warsaw's request, this note is provided for historical purposes.
He has implemented similar functionality in a cleaner way.]

When nntplib is used on a machine that is an NNTP peer of the news server,
it defaults to "feeder" mode.  It is useful to have an optional keyword
argument to __init__ to select "mode reader" to get NNRP functionality prior
to authentication or other commands.  Default operation of NNTP is
unchanged.

I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims").  To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.

I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation.  I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.

Jim Tittsler, Tokyo
jwt@dskk.co.jp


--yrj/dFKFPuw6o+aM
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)

--yrj/dFKFPuw6o+aM--