[Twisted-Python] PIRP for Twisted Python

Moshe Zadka moshez at lerner.co.il
Wed Apr 18 03:04:00 EDT 2001

Hello, dear Twisted developers!

Attached is a twisted.protocol for PIRP, DJB's publishing protocol.
I think it would be interesting to write an interface for twisted.web
so Resources would be publishable both by the web and by PIRP (and
possibly, later, other protocols?)
The big point would probably to think up an interface to the request
which is portable enough.

I think something like:
  - request.components(): return the requested path as a list of components
  - request.received_headers(): return the headers
  - request.write(packet): write a packet to the user

I'm still not sure how to signal failure: while in PIRP there's a single
form of failure, HTTP defines millions of them.
Anyway, I'll go off an implement a PIRP client now.
Moshe Zadka <moshez at lerner.co.il>
Web Developer, Python Developer

import NetstringReceiver

class PIRPHandler(NetstringReceiver.NetstringReceiver):

    __buffer = None

    def handleString(self, s):
        if s:
            if self.__buffer is None:
                self.__buffer = []
            buffer, self.__buffer = self.__buffer, None

    def sendError(self):

    def sendPacket(self, packet):
        self.write('%d:%s,' % (len(packet), packet)))

    def endPackets(self):

    def sendPackets(self, packets):
        for packet in packets:
Moshe Zadka <moshez at lerner.co.il>
Web Developer, Python Developer

More information about the Twisted-Python mailing list