Using nntplib

Pedro RODRIGUEZ pedro_rodriguez at club-internet.fr
Sat Jun 1 08:38:23 EDT 2002


On Fri, 31 May 2002 12:19:00 +0200, jb wrote:

> The best possibility seems to me, to rewrite nntplib, so that it fits in
> with Qt and as the NNTP protocol is very simple and nntplib is very
> clearly written, this seems to be simple. Maybe I shall try it.
 
Better have some hook/callback mechanism defined somewhere as you already
stated, or some kind of generator you could activate on will - but this
will be less effecient.

Don't know if this can help 
- python2.2 only and use longcmd which is not part of the public interface :

import nntplib

class MyListHook:
    def __init__(self):
        self.reset()

    def reset(self):
        self.count = 0
        self.list = []

    def write(self, line):
        self.count = self.count + 1
        self.list.append(tuple(line.split()))
        # print "GOT : %s" % line

class MyNNTP(nntplib.NNTP):
    def mylist(self, hook):
        resp, list = self.longcmd('LIST', hook)
        return resp, hook.list

n = MyNNTP("localhost")
h = MyListHook()
print n.mylist(h)

Regards,
Pedro

"Il n'y a guère dans l'amor qu'une préoccupation grave: c'est l'envie;" 
(Désolé ;)



More information about the Python-list mailing list