[Twisted-Python] Completely new to twisted - where to get some background?
Jp Calderone
exarkun at meson.dyndns.org
Sun Oct 20 17:34:35 MDT 2002
On Sat, Oct 19, 2002 at 11:36:15PM +0100, Paul Moore wrote:
> I'm totally new to twisted - I downloaded it because I'd heard that it
> could support being an NNTP server. But I can't get my head round the
> documentation. I'm not even sure where to begin - am I a user, an
> administrator, or what?
>
> Basically, what I want to do is to set up an NNTP server which serves
> out the contents of a series of mbox files as newsgroups. I'm guessing
> that I need to code up some sort of "backend" code, which will fit
> into the twisted structure somewhere. But I can't find enough from the
> documentation to know where to start.
From this, I'd say that you're probably going to be a developer, an
administrator, and a user. ;)
The current NNTP code lets you use one of two different backends - a
pickle file or an RDBM (postgres is what was used to develop it). To serve
news out of mbox files, you'll need to write another backend that implements
the NewsStorage interface (twisted.news.database.NewsStorage), then hand
this to either an NNTPServerFactory or a UsenetServerFactory (probably the
former). It would be nice if 'mktap news' could handle this, but it can't
(yet), so you'll have to write a little more python to glue it all together.
twisted.tap.news.updateApplication() is definitely something you'll want to
look at. The Application Howto and the Server Howto are probably worth
going over:
http://twistedmatrix.com/documents/howto/application
http://twistedmatrix.com/documents/howto/servers
You shouldn't need to write a Factory or a Protocol to do what you want,
but knowing how the pieces fit together will probably be beneficial.
Depending if you try to make "queries" to the mbox synchronous or not, the
Deferred howto might be relevant as well:
http://twistedmatrix.com/documents/howto/defer
Twisted usually considers disk operations (and certainly memory
operations) fast enough to not worry about this, though, so doing what the
PickleStorage class does (defer.fail(), defer.succeed()) will probably work
for you.
>
> Can someone point me at some sort of "gentle introduction" to this
> sort of task? (Or alternatively, let me know if twisted is *not* the
> appropriate application for this!)
Twisted is definitely suited for this :) I'm not aware of a document that
is directly relevant to what you want to do, because it's not too deeply
related to Twisted. Hopefully what needs to be done will be clear after you
check out the code I mentioned above.
Jp
--
"One World, one Web, one Program." - Microsoft(R) promotional ad
"Ein Volk, ein Reich, ein Fuhrer." - Adolf Hitler
--
7:00pm up 152 days, 19:58, 2 users, load average: 0.14, 0.09, 0.07
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20021020/75b4afa5/attachment.sig>
More information about the Twisted-Python
mailing list