Andrew Vant <ajv...@gmail.com> added the comment:

At Antoine's suggestion I've written a new patch for this for 3.2, adding 
support for both SSL on 563 and STARTTLS on a normal connection. A NNTP_SSL 
class supports the former and a NNTP.starttls() method supports the latter. As 
a side effect of getting starttls working I had to add a NNTP.login() method as 
well. (see below)

The patch updates nntplib.py, test_nntplib.py, nntplib.rst, and Misc/NEWS. 

Some implementation notes: 

By default, NNTP objects attempt to log in during initialization,and there 
didn't seem to be any support for logging in later. This was a problem as 
STARTTLS has to be issued before logging in. In order to get around this and 
handle a STARTTLS nuance involving CAPABILITIES, I moved the authentication 
part of _NNTPBase.__init__ into a method of its own, NNTP.login(), and another 
piece of it into NNTP.getcapabilities(). This doesn't affect the observable 
behavior of NNTP() or the existing methods.

As a side note, IMHO NNTP shouldn't attempt to log in at initialization at all. 
The user, password, and usenetrc args should not be part of the constructors 
and the program using the library should be able to choose when or if to log in 
after connecting. I couldn't think of any way to do this without breaking 
existing programs, though. At the very least I think usenetrc should default to 
False, but that would break programs that rely on the default behavior too, I 
think. 

I updated the test cases, with a caveat. They use gmane to perform the tests. 
Gmane doesn't support starttls. Therefor the tests currently only check for 
correct failure rather than correct success. There's test code for the 
starttls() method but it never runs. I checked the functionality against 
eternal-september to be sure it does, in fact, correctly succeed as well, but 
I'm not about to put my login details in the automatic test script. ;-) 

The NNTPS-on-563 test, OTOH, works exactly like the existing NNTP test and 
seems to work fine. It was a hell of a lot easier to implement that part too.

Hope I didn't miss anything. First time doing this for a public project. 
Apparently the personal-itch theory is correct.

<click>

----------
nosy: +ajvant
Added file: http://bugs.python.org/file19463/python_nntp_ssl_patch1.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1926>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to