Add to the branche tcp-ipv6-3014

[email protected]
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from victorvieux <None>:

Hello,

I have 3 modifications to the branche tcp-ipv6-3014 :

'''1 Add web2 to setup.py'''
{{{
--- setup.py    (revision 26995)
+++ setup.py    (working copy)
@@ -18,7 +18,7 @@
 import sys, os, glob
 
 sumoSubprojects = ['core', 'conch', 'lore', 'mail', 'names',
-                   'runner', 'web', 'words', 'news']
+                   'runner', 'web', 'words', 'news', 'web2']
}}}
'''2 Add a TCP6Server and TCP6Client to application.internet'''
{{{
--- twisted/application/internet.py     (revision 26995)
+++ twisted/application/internet.py     (working copy)
@@ -15,6 +15,7 @@
 They are as follows::
 
   TCPServer, TCPClient,
+  TCP6Server, TCP6Client,
   UNIXServer, UNIXClient,
   SSLServer, SSLClient,
   UDPServer, UDPClient,
@@ -58,11 +59,11 @@
     @type volatile: C{list}
 
     @ivar method: the type of method to call on the reactor, one of B{TCP},
-        B{UDP}, B{SSL} or B{UNIX}.
+        B{TCP6}, B{UDP}, B{SSL} or B{UNIX}.
     @type method: C{str}
 
     @ivar reactor: the current running reactor.
-    @type reactor: a provider of C{IReactorTCP}, C{IReactorUDP},
+    @type reactor: a provider of C{IReactorTCP}, C{IReactorTCP6}, C{IReactorUDP},
         C{IReactorSSL} or C{IReactorUnix}.
 
     @ivar _port: instance of port set when the service is started.
@@ -125,11 +126,11 @@
     @type volatile: C{list}
 
     @ivar method: the type of method to call on the reactor, one of B{TCP},
-        B{UDP}, B{SSL} or B{UNIX}.
+        B {TCP6}, B{UDP}, B{SSL} or B{UNIX}.
     @type method: C{str}
 
     @ivar reactor: the current running reactor.
-    @type reactor: a provider of C{IReactorTCP}, C{IReactorUDP},
+    @type reactor: a provider of C{IReactorTCP}, C{IReactorTCP6}, C{IReactorUDP},
         C{IReactorSSL} or C{IReactorUnix}.
 
     @ivar _connection: instance of connection set when the service is started.
@@ -194,7 +195,7 @@
 }
 
 import new
-for tran in 'Generic TCP UNIX SSL UDP UNIXDatagram Multicast'.split():
+for tran in 'Generic TCP TCP6 UNIX SSL UDP UNIXDatagram Multicast'.split():
     for side in 'Server Client'.split():
         if tran == "Multicast" and side == "Client":
             continue
}}}
'''3 Add Resource6 and PostableResource6 to web2 to remove unparseURL (doesn't work with ipv6)'''
{{{
--- twisted/web2/resource.py    (revision 26995)
+++ twisted/web2/resource.py    (working copy)
@@ -201,7 +201,18 @@
 
         return super(Resource, self).http_GET(request)
 
+class Resource6(Resource):
+    """
+    Resource without unparseURL (doesn't work with ipv6).
+    """
+    def http_GET(self, request):
+        if self.addSlash and request.prepath[-1] != '':
+            # If this is a directory-ish resource...                     
+            return http.RedirectResponse(request.path+'/')
+        return super(Resource6, self).http_GET(request)
 
+
+
 class PostableResource(Resource):
     """
     A L{Resource} capable of handling the POST request method.
@@ -229,7 +240,28 @@
             self.maxMem, self.maxFields, self.maxSize
             ).addCallback(lambda res: self.render(request))
 
+class PostableResource6(Resource6):
+    """
+    PostableResource without unparseURL (doesn't work with ipv6).
+    """
 
+    maxMem = 100 * 1024
+    maxFields = 1024
+    maxSize = 10 * 1024 * 1024
+
+    def http_POST(self, request):
+        """
+        Respond to a POST request.
+        Reads and parses the incoming body data then calls L{render}.
+
+        @param request: the request to process.
+        @return: an object adaptable to L{iweb.IResponse}.
+        """
+        return server.parsePOSTData(request,
+            self.maxMem, self.maxFields, self.maxSize
+            ).addCallback(lambda res: self.render(request))
+
+
 class LeafResource(RenderMixin):
     """
     A L{Resource} with no children.
@@ -292,4 +324,5 @@
         return self.resource
 
 
-__all__ = ['RenderMixin', 'Resource', 'PostableResource', 'LeafResource', 'WrapperResource']
+__all__ = ['RenderMixin', 'Resource', 'Resource6', 'PostableResource',
+           'PostableResource6', 'LeafResource', 'WrapperResource']
}}}

----------
Type     : enhancement
Component: web2
Keywords : ipv6 TCP6Server
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/3881
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.