Ticket #6078 enhancement closed fixed

Opened 19 months ago

Last modified 19 months ago

Port twisted.web.resource to Python 3

Reported by: exarkun Owned by: exarkun
Priority: normal Milestone: Python 3.3 Minimal
Component: web Keywords:
Cc: jknight Branch: branches/resource-py3-6078-2
(diff, github, buildbot, log)
Author: exarkun Launchpad Bug:

Description

The basis of the resource publishing model for the Twisted Web server.

Change History

1

Changed 19 months ago by DefaultCC Plugin

  • cc jknight added

2

Changed 19 months ago by exarkun

  • branch set to branches/resource-py3-6078
  • branch_author set to exarkun

(In [36108]) Branching to 'resource-py3-6078'

3

Changed 19 months ago by exarkun

Basically done, I think, except:

  1. depends on prefixedMethodNames (#6100)
  2. I threw some encode('ascii') and decode('ascii') in. They get the job done in the naive case, but maybe they merit some additional error handling code? Or something? Or maybe 'latin-1' is a better charset to use. Also, maybe they suck for the Python 2 case - time for another string type/compat helper?

Maybe other stuff is terrible about this too, but those stand out to me.

4

Changed 19 months ago by exarkun

  • keywords review added
  • owner changed from exarkun to itamar

Still depends on #6100 being resolved first.

5

Changed 19 months ago by itamar

  • keywords review removed
  • owner changed from itamar to exarkun

Nice to see extra tests.

  1. I'm fine with HTTP methods being ASCII only (latin-1 doesn't make sense to me; I suppose it's possible RFC will be expanded to be UTF-8 someday, but not that). For the decode case, nativeString is what you want to use, I believe; in particular since on Python 2 this is a slightly more expensive way of doing what the current trunk code does, so no change or potential for new errors. For the encode... we could create nativeStringToBytes? I suppose if we find another instance where this is necessary we should create it, but for now I'd say just leave it as is.
  2. Resource and IResource could use some addition and clarification of the types of parameters. E.g. IResource doesn't mention types at all, and Resource says string when it means bytes.
  3. Resource.getChild code example should indicate bytes, likewise putChild.
  4. Add the byteness of path elements to the porting howto.

Fix the above, then merge (after #6100 I guess).

6

Changed 19 months ago by exarkun

(In [36145]) Fixes to string types used by ErrorPage-related code.

refs #6078

7

Changed 19 months ago by exarkun

  • branch changed from branches/resource-py3-6078 to branches/resource-py3-6078-2

(In [36147]) Branching to 'resource-py3-6078-2'

8

Changed 19 months ago by exarkun

I'm fine with HTTP methods being ASCII only (latin-1 doesn't make sense to me; I suppose it's possible RFC will be expanded to be UTF-8 someday, but not that). For the decode case, nativeString is what you want to use, I believe; in particular since on Python 2 this is a slightly more expensive way of doing what the current trunk code does, so no change or potential for new errors. For the encode... we could create nativeStringToBytes? I suppose if we find another instance where this is necessary we should create it, but for now I'd say just leave it as is.

Switched to nativeString and added a comment for the encode case in r36142.

Resource and IResource could use some addition and clarification of the types of parameters. E.g. IResource doesn't mention types at all, and Resource says string when it means bytes. Resource.getChild code example should indicate bytes, likewise putChild.

Fixed in r36143.

Add the byteness of path elements to the porting howto.

Did that in r36144.

Also fixed some ErrorPage stuff in r36145 and r36146.

9

Changed 19 months ago by exarkun

  • status changed from new to closed
  • resolution set to fixed

(In [36151]) Merge resource-py3-6078-2

Author: exarkun Reviewer: itamarst Fixes: #6078

Port twisted.web.error and twisted.web.resource to Python 3. Also add some unit tests for twisted.web.resource.Resource which were previously missing.

Note: See TracTickets for help on using tickets.