[Twisted-Python] PIRP for Twisted Python
18 Apr 2001 18 Apr '01
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 email@example.com 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 =  self.__buffer.append(s) else: buffer, self.__buffer = self.__buffer, None self.handlePIRP(buffer) def sendError(self): self.write('!') def sendPacket(self, packet): self.write('%d:%s,' % (len(packet), packet))) def endPackets(self): self.sendPacket('') def sendPackets(self, packets): for packet in packets: self.sendPacket(packet) self.endPackets() -- Moshe Zadka firstname.lastname@example.org Web Developer, Python Developer
Age (days ago)
Last active (days ago)