[Twisted-Python] Are t.w.s.Requests's prepath/postpath part of the IRequest interface?

Glyph glyph at twistedmatrix.com
Sun Mar 10 21:06:12 MDT 2019

> On Mar 7, 2019, at 5:42 PM, Wim Lewis <wiml at hhhh.org> wrote:
> I was just working on the documentation to fix Trac bug #5533, but I 
> have a question about intent. Right now, prepath and postpath are 
> undocumented; as best as I can tell, though, they are intended to be 
> public. Question is, are they part of the IRequest interface, or only of 
> the Request implementation?

I think that this is a bit of a special case, in that *normally* if something isn’t mentioned in an interface you need to add a new interface, it’s an incompatible change to add it, etc; but, functionally, there are a bunch of things you can’t really implement with the current IRequest unless you assume it has .prepath and .postpath attributes.  If someone has an IRequest proxy today it really needs to special case those attributes or it will be unusable for all but the most trivial applications.

So yeah: let’s correct the documentation here, and add them.

> (There aren't any other implementations of IRequest in Twisted, so I 
> suppose it's a little bit academic.)

Also, yeah, that.

> It seems to me that they should be on IRequest, since IRequest already 
> has methods like prePathURL() which depend on the information in 
> prepath/postpath. Leaving these attributes off of IRequest wouldn't 
> provide any more flexibility to implementers of the interface, and 
> postpath in particular is very useful to people writing render methods.
> <https://twistedmatrix.com/trac/ticket/5533>

Agreed on all counts.

More information about the Twisted-Python mailing list