home *** CD-ROM | disk | FTP | other *** search
- <TITLE>NNTP Objects -- Python library reference</TITLE>
- Prev: <A HREF="../n/nntplib" TYPE="Prev">nntplib</A>
- Up: <A HREF="../n/nntplib" TYPE="Up">nntplib</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H2>10.6.1. NNTP Objects</H2>
- NNTP instances have the following methods. The <VAR>response</VAR> that is
- returned as the first item in the return tuple of almost all methods
- is the server's response: a string beginning with a three-digit code.
- If the server's response indicates an error, the method raises one of
- the above exceptions.
- <P>
- <DL><DT><B>getwelcome</B> () -- Method on NNTP object<DD>
- Return the welcome message sent by the server in reply to the initial
- connection. (This message sometimes contains disclaimers or help
- information that may be relevant to the user.)
- </DL>
- <DL><DT><B>set_debuglevel</B> (<VAR>level</VAR>) -- Method on NNTP object<DD>
- Set the instance's debugging level. This controls the amount of
- debugging output printed. The default, 0, produces no debugging
- output. A value of 1 produces a moderate amount of debugging output,
- generally a single line per request or response. A value of 2 or
- higher produces the maximum amount of debugging output, logging each
- line sent and received on the connection (including message text).
- </DL>
- <DL><DT><B>newgroups</B> (<VAR>date</VAR>, <VAR>time</VAR>) -- Method on NNTP object<DD>
- Send a `<SAMP>NEWGROUPS</SAMP>' command. The <VAR>date</VAR> argument should be a
- string of the form <CODE>"<VAR>yy</VAR><VAR>mm</VAR><VAR>dd</VAR>"</CODE> indicating the
- date, and <VAR>time</VAR> should be a string of the form
- <CODE>"<VAR>hh</VAR><VAR>mm</VAR><VAR>ss</VAR>"</CODE> indicating the time. Return a pair
- <CODE>(<VAR>response</VAR>, <VAR>groups</VAR>)</CODE> where <VAR>groups</VAR> is a list of
- group names that are new since the given date and time.
- </DL>
- <DL><DT><B>newnews</B> (<VAR>group</VAR>, <VAR>date</VAR>, <VAR>time</VAR>) -- Method on NNTP object<DD>
- Send a `<SAMP>NEWNEWS</SAMP>' command. Here, <VAR>group</VAR> is a group name or
- <CODE>"*"</CODE>, and <VAR>date</VAR> and <VAR>time</VAR> have the same meaning as for
- <CODE>newgroups()</CODE>. Return a pair <CODE>(<VAR>response</VAR>,
- <VAR>articles</VAR>)</CODE> where <VAR>articles</VAR> is a list of article ids.
- </DL>
- <DL><DT><B>list</B> () -- Method on NNTP object<DD>
- Send a `<SAMP>LIST</SAMP>' command. Return a pair <CODE>(<VAR>response</VAR>,
- <VAR>list</VAR>)</CODE> where <VAR>list</VAR> is a list of tuples. Each tuple has the
- form <CODE>(<VAR>group</VAR>, <VAR>last</VAR>, <VAR>first</VAR>, <VAR>flag</VAR>)</CODE>, where
- <VAR>group</VAR> is a group name, <VAR>last</VAR> and <VAR>first</VAR> are the last
- and first article numbers (as strings), and <VAR>flag</VAR> is <CODE>'y'</CODE>
- if posting is allowed, <CODE>'n'</CODE> if not, and <CODE>'m'</CODE> if the
- newsgroup is moderated. (Note the ordering: <VAR>last</VAR>, <VAR>first</VAR>.)
- </DL>
- <DL><DT><B>group</B> (<VAR>name</VAR>) -- Method on NNTP object<DD>
- Send a `<SAMP>GROUP</SAMP>' command, where <VAR>name</VAR> is the group name.
- Return a tuple <CODE>(<VAR>response</VAR>, <VAR>count</VAR>, <VAR>first</VAR>,
- <VAR>last</VAR>, <VAR>name</VAR>)</CODE> where <VAR>count</VAR> is the (estimated) number
- of articles in the group, <VAR>first</VAR> is the first article number in
- the group, <VAR>last</VAR> is the last article number in the group, and
- <VAR>name</VAR> is the group name. The numbers are returned as strings.
- </DL>
- <DL><DT><B>help</B> () -- Method on NNTP object<DD>
- Send a `<SAMP>HELP</SAMP>' command. Return a pair <CODE>(<VAR>response</VAR>,
- <VAR>list</VAR>)</CODE> where <VAR>list</VAR> is a list of help strings.
- </DL>
- <DL><DT><B>stat</B> (<VAR>id</VAR>) -- Method on NNTP object<DD>
- Send a `<SAMP>STAT</SAMP>' command, where <VAR>id</VAR> is the message id (enclosed
- in `<SAMP><</SAMP>' and `<SAMP>></SAMP>') or an article number (as a string).
- Return a triple <CODE>(varresponse, <VAR>number</VAR>, <VAR>id</VAR>)</CODE> where
- <VAR>number</VAR> is the article number (as a string) and <VAR>id</VAR> is the
- article id (enclosed in `<SAMP><</SAMP>' and `<SAMP>></SAMP>').
- </DL>
- <DL><DT><B>next</B> () -- Method on NNTP object<DD>
- Send a `<SAMP>NEXT</SAMP>' command. Return as for <CODE>stat()</CODE>.
- </DL>
- <DL><DT><B>last</B> () -- Method on NNTP object<DD>
- Send a `<SAMP>LAST</SAMP>' command. Return as for <CODE>stat()</CODE>.
- </DL>
- <DL><DT><B>head</B> (<VAR>id</VAR>) -- Method on NNTP object<DD>
- Send a `<SAMP>HEAD</SAMP>' command, where <VAR>id</VAR> has the same meaning as for
- <CODE>stat()</CODE>. Return a pair <CODE>(<VAR>response</VAR>, <VAR>list</VAR>)</CODE>
- where <VAR>list</VAR> is a list of the article's headers (an uninterpreted
- list of lines, without trailing newlines).
- </DL>
- <DL><DT><B>body</B> (<VAR>id</VAR>) -- Method on NNTP object<DD>
- Send a `<SAMP>BODY</SAMP>' command, where <VAR>id</VAR> has the same meaning as for
- <CODE>stat()</CODE>. Return a pair <CODE>(<VAR>response</VAR>, <VAR>list</VAR>)</CODE>
- where <VAR>list</VAR> is a list of the article's body text (an
- uninterpreted list of lines, without trailing newlines).
- </DL>
- <DL><DT><B>article</B> (<VAR>id</VAR>) -- Method on NNTP object<DD>
- Send a `<SAMP>ARTICLE</SAMP>' command, where <VAR>id</VAR> has the same meaning as
- for <CODE>stat()</CODE>. Return a pair <CODE>(<VAR>response</VAR>, <VAR>list</VAR>)</CODE>
- where <VAR>list</VAR> is a list of the article's header and body text (an
- uninterpreted list of lines, without trailing newlines).
- </DL>
- <DL><DT><B>slave</B> () -- Method on NNTP object<DD>
- Send a `<SAMP>SLAVE</SAMP>' command. Return the server's <VAR>response</VAR>.
- </DL>
- <DL><DT><B>xhdr</B> (<VAR>header</VAR>, <VAR>string</VAR>) -- Method on NNTP object<DD>
- Send an `<SAMP>XHDR</SAMP>' command. This command is not defined in the RFC
- but is a common extension. The <VAR>header</VAR> argument is a header
- keyword, e.g. <CODE>"subject"</CODE>. The <VAR>string</VAR> argument should have
- the form <CODE>"<VAR>first</VAR>-<VAR>last</VAR>"</CODE> where <VAR>first</VAR> and
- <VAR>last</VAR> are the first and last article numbers to search. Return a
- pair <CODE>(<VAR>response</VAR>, <VAR>list</VAR>)</CODE>, where <VAR>list</VAR> is a list of
- pairs <CODE>(<VAR>id</VAR>, <VAR>text</VAR>)</CODE>, where <VAR>id</VAR> is an article id
- (as a string) and <VAR>text</VAR> is the text of the requested header for
- that article.
- </DL>
- <DL><DT><B>post</B> (<VAR>file</VAR>) -- Method on NNTP object<DD>
- Post an article using the `<SAMP>POST</SAMP>' command. The <VAR>file</VAR>
- argument is an open file object which is read until EOF using its
- <CODE>readline()</CODE> method. It should be a well-formed news article,
- including the required headers. The <CODE>post()</CODE> method
- automatically escapes lines beginning with `<SAMP>.</SAMP>'.
- </DL>
- <DL><DT><B>ihave</B> (<VAR>id</VAR>, <VAR>file</VAR>) -- Method on NNTP object<DD>
- Send an `<SAMP>IHAVE</SAMP>' command. If the response is not an error, treat
- <VAR>file</VAR> exactly as for the <CODE>post()</CODE> method.
- </DL>
- <DL><DT><B>quit</B> () -- Method on NNTP object<DD>
- Send a `<SAMP>QUIT</SAMP>' command and close the connection. Once this method
- has been called, no other methods of the NNTP object should be called.
- </DL>
-