[Patches] [ python-Patches-720468 ] nntplib file output for multiline commands

SourceForge.net noreply@sourceforge.net
Fri, 18 Apr 2003 18:56:21 -0700


Patches item #720468, was opened at 2003-04-13 00:34
Message generated for change (Comment added) made by tcarroll
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=720468&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Terry Carroll (tcarroll)
Assigned to: Guido van Rossum (gvanrossum)
Summary: nntplib file output for multiline commands

Initial Comment:
This patch extends the support for file output,
currently supported only for the body() method (added
by Travers Naran in patch 462628) to all the other
methods that invoke NNTP commands that produce
multiline output; in particular: newgroups(),
newnews(), list(), help(), xhdr(), xgtitle() and xover().

Many of these commands, especially list(), newgroups()
and xhdr(), produce a large amount of output, and
requiring that the output be maintained in memory, as
in the present implementation, may impair performance
of the application or the entire system, in
limited-resource configurations.  Routing the output to
a file avoids this (and, if the file object is actually
a subclass of the file class, the programmer can supply
a write method that processes the NNTP command output
as it is produced).

The file parameter added by this patch is consistent
with its present use in the body() method, specifying
either a string containing a file name, or an open file
object.

----------------------------------------------------------------------

>Comment By: Terry Carroll (tcarroll)
Date: 2003-04-19 01:56

Message:
Logged In: YES 
user_id=755895

Thanks, Guido.

I'd have saved time if I implemented your second comment
first  :-)

Changes made (dropping the guard makes the "File == None" v.
"File is None" issue moot) and tested.  

I get an error trying to delete the previously uploaded
nntplib diff.  The one commented  "nntplib code diff" is the
right one.  The other can be deleted.


----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-04-18 16:18

Message:
Logged In: YES 
user_id=6380

Two comments:

- Instead of "if file == None" you should test for "if file
is None".

- In several routines you added "if file == None" guards
around a for loop over the lines returned by
self.longcmd(...).  But self.longcmd() returns an empty list
if given a file argument, so the for loop would execute zero
times. I think it's better to drop the guard and simply let
the empty loop take care of things.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=720468&group_id=5470