rpms/python-twisted-web2/EL-5 python-twisted-web2.spec, NONE, 1.1 twisted-web2_0.2.0-1.1.diff, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
Matthias Saou
thias at fedoraproject.org
Thu Jan 1 11:18:56 UTC 2009
- Previous message (by thread): rpms/python-twisted-web2/F-10 python-twisted-web2.spec, NONE, 1.1 twisted-web2_0.2.0-1.1.diff, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
- Next message (by thread): rpms/python-twisted-web2/F-9 python-twisted-web2.spec, NONE, 1.1 twisted-web2_0.2.0-1.1.diff, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: thias
Update of /cvs/extras/rpms/python-twisted-web2/EL-5
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26946/EL-5
Modified Files:
.cvsignore sources
Added Files:
python-twisted-web2.spec twisted-web2_0.2.0-1.1.diff
Log Message:
Initial import of older 0.2.0 + patch on stable branches (pre Twisted 8).
--- NEW FILE python-twisted-web2.spec ---
%{!?python:%define python python}
%{!?python_sitearch: %define python_sitearch %(%{python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
Summary: Experimental Twisted Web Server Framework
Name: %{python}-twisted-web2
Version: 0.2.0
Release: 3%{?dist}
License: MIT
Group: Development/Libraries
URL: http://twistedmatrix.com/trac/wiki/TwistedWeb2
Source: http://tmrc.mit.edu/mirror/twisted/Web2/TwistedWeb2-%{version}.tar.bz2
Patch0: twisted-web2_0.2.0-1.1.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: %{python}-twisted-core >= 8.1.0
BuildRequires: %{python}-devel
# Files are noarch, but we need to install in sitearch for things to work, as
# all the rest of Twisted is in sitearch
#BuildArch: noarch
# Because of the above, disable generating an empty debuginfo package
%define debug_package %{nil}
%description
Twisted.Web2 is an experimental web server built with Twisted. Useful Web2
functionality will be backported to TwistedWeb until TwistedWeb is as
featureful as Web2, then Web2 will be abandoned.
%prep
%setup -q -n TwistedWeb2-%{version}
%patch0 -p1
%build
%{__python} setup.py build
%install
%{__rm} -rf %{buildroot}
%{__python} setup.py install \
-O1 --skip-build --root %{buildroot} \
--install-purelib %{python_sitearch}
# See if there's any egg-info
if [ -f %{buildroot}%{python_sitearch}/Twisted*.egg-info ]; then
echo %{buildroot}%{python_sitearch}/Twisted*.egg-info |
%{__sed} -e 's|^%{buildroot}||'
fi > egg-info
%clean
%{__rm} -rf %{buildroot}
%post
if [ -x %{_libexecdir}/twisted-dropin-cache ]; then
%{_libexecdir}/twisted-dropin-cache || :
fi
%postun
if [ -x %{_libexecdir}/twisted-dropin-cache ]; then
%{_libexecdir}/twisted-dropin-cache || :
fi
%files -f egg-info
%defattr(-,root,root,-)
%doc LICENSE NEWS README
%{python_sitearch}/twisted/plugins/twisted_web2.py*
%{python_sitearch}/twisted/web2/
%changelog
* Thu Jan 1 2009 Matthias Saou <http://freshrpms.net/> 0.2.0-3
- Backport cosmetic changes from 8.1.0 devel spec to here. This will be an
older build to go with Twisted < 8.
* Wed Jul 16 2008 Matthias Saou <http://freshrpms.net/> 0.2.0-2
- Downgrade to 0.2.0 as elisa doesn't work with 8.1.0.
- Include Debian's patch, as it changes quite a bit of code.
* Tue Jul 15 2008 Matthias Saou <http://freshrpms.net/> 8.1.0-0.1
- Initial RPM release.
twisted-web2_0.2.0-1.1.diff:
--- NEW FILE twisted-web2_0.2.0-1.1.diff ---
--- twisted-web2-0.2.0.orig/twisted/web2/stream.py
+++ twisted-web2-0.2.0/twisted/web2/stream.py
@@ -999,17 +999,29 @@
return self._readUntil(gotdata)
- def readline(self, delimiter='\r\n', maxLength=None):
+ def readline(self, delimiter='\r\n', maxLength=None, size=None):
"""Read a line of data from the string, bounded by delimiter"""
+ if size is not None and size < 0:
+ raise ValueError("readExactly: size cannot be negative: %s", size)
+
def gotdata():
- data = self.data.split(delimiter, 1)
+ postdata = ''
+ predata = self.data
+ if size is not None and len(predata) >= size:
+ predata, postdata = predata[:size], predata[size:]
+ data = predata.split(delimiter, 1)
if len(data) == 2:
- self.data=data[1]
+ self.data=data[1] + postdata
if maxLength and len(data[0]) > maxLength:
- raise LineTooLongException(data[0])
+ raise RuntimeError(
+ "Line data too long at %d" % len(data[0]))
return data[0]
+ elif size is not None: # len(data) == 1
+ if postdata:
+ self.data = postdata
+ return predata
if maxLength and len(self.data) > maxLength:
- raise LineTooLongException(self.data)
+ raise RuntimeError("Line data too long at %d" % len(self.data))
return self._readUntil(gotdata)
def pushback(self, pushed):
--- twisted-web2-0.2.0.orig/twisted/web2/test/test_stream.py
+++ twisted-web2-0.2.0/twisted/web2/test/test_stream.py
@@ -128,8 +128,7 @@
self.assertRaises(ValueError, self.makeStream, 0, 20)
-class TestSubstream(unittest.TestCase):
- data = """I was angry with my friend:
+testdata = """I was angry with my friend:
I told my wrath, my wrath did end.
I was angry with my foe:
I told it not, my wrath did grow.
@@ -148,8 +147,11 @@
When the night had veil'd the pole:
In the morning glad I see
My foe outstretch'd beneath the tree"""
+
+class TestSubstream(unittest.TestCase):
def setUp(self):
+ self.data = testdata
self.s = stream.MemoryStream(self.data)
def suckTheMarrow(self, s):
@@ -178,7 +180,55 @@
def testPastEnd(self):
size = len(self.data)
self.assertRaises(ValueError, stream.substream, self.s, size-4, size+8)
-
+
+
+class TestBufferedStream(unittest.TestCase):
+
+ def setUp(self):
+ self.data = testdata.replace('\n', '\r\n')
+ s = stream.MemoryStream(self.data)
+ self.s = stream.BufferedStream(s)
+
+ def _cbGotData(self, data, expected):
+ self.assertEqual(data, expected)
+
+ def test_readline(self):
+ d = self.s.readline()
+ d.addCallback(self._cbGotData, 'I was angry with my friend:')
+ return d
+
+ def test_readline_size(self):
+ d = self.s.readline(size = 5)
+ d.addCallback(self._cbGotData, 'I was')
+ return d
+
+ def test_readline_zero(self):
+ d = self.s.readline(size = 0)
+ d.addCallback(self._cbGotData, '')
+ return d
+
+ def test_readline_finished(self):
+ nolines = len(self.data.split('\r\n'))
+ for i in range(nolines):
+ self.s.readline()
+ d = self.s.readline()
+ d.addCallback(self._cbGotData, '')
+ return d
+
+ def test_readline_sizeneg(self):
+ self.assertRaises(ValueError, self.s.readline, size = -1)
+
+ def test_readline_maxlength(self):
+ d = self.s.readline(maxLength = 1)
+ self.assertFailure(d, RuntimeError)
+
+ def test_readExactly(self):
+ d = self.s.readExactly()
+ d.addCallback(self._cbGotData, self.data)
+ return d
+
+ def test_read(self):
+ self.assertEqual(str(self.s.read()), self.data)
class TestStreamer:
implements(stream.IStream, stream.IByteStream)
--- twisted-web2-0.2.0.orig/twisted/web2/test/test_wsgi.py
+++ twisted-web2-0.2.0/twisted/web2/test/test_wsgi.py
@@ -162,6 +162,44 @@
(WSGI(application), 'http://host/', {}, None, None, '', "These\nare\nlines"),
(200, {"Content-Length": 18}, "These\nXare\nXlines\n"))
+ def test_readInputLineSizeNegZero(self):
+ def application(environ, start_response):
+ input = environ['wsgi.input']
+
+ out = [input.read(5)] # 'Line '
+ out += ["X", input.readline(-1)] # 'blah blah\n'
+ out += ["X", input.readline(0)] # ''
+ out += ["X", input.readline(-1)] # 'Oh Line\n'
+ out += ["X", input.readline()] # ''
+
+ start_response("200 OK", {})
+ return out
+
+ return self.assertResponse(
+ (WSGI(application), 'http://host/', {}, None, None, '',
+ "Line blah blah\nOh Line\n"),
+ (200, {"Content-Length": 27},
+ "Line Xblah blah\nXXOh Line\nX"))
+
+ def test_readInputLineSize(self):
+ def application(environ, start_response):
+ input = environ['wsgi.input']
+
+ out = [input.read(5)] # 'Line '
+ out += ["X", input.readline(5)] # 'blah '
+ out += ["X", input.readline()] # 'blah\n'
+ out += ["X", input.readline(1)] # '0'
+ out += ["X", input.readline()] # 'h Line\n'
+
+ start_response("200 OK", {})
+ return out
+
+ return self.assertResponse(
+ (WSGI(application), 'http://host/', {}, None, None, '',
+ "Line blah blah\nOh Line\n"),
+ (200, {"Content-Length": 27},
+ "Line Xblah Xblah\nXOXh Line\n"))
+
def test_readInputMixed(self):
def application(environ, start_response):
input = environ['wsgi.input']
@@ -174,7 +212,8 @@
return out
return self.assertResponse(
- (WSGI(application), 'http://host/', {}, None, None, '', "Line blah blah\nOh Line\n"),
+ (WSGI(application), 'http://host/', {}, None, None, '',
+ "Line blah blah\nOh Line\n"),
(200, {"Content-Length": 26}, "Line Xblah blah\nXOXh Line\n"))
class TestWSGIEnvironment(BaseCase):
--- twisted-web2-0.2.0.orig/twisted/web2/wsgi.py
+++ twisted-web2-0.2.0/twisted/web2/wsgi.py
@@ -65,9 +65,28 @@
size = None
return callInReactor(self.stream.readExactly, size)
- def readline(self):
+ def readline(self, size=None):
# Called in application thread
- return callInReactor(self.stream.readline, '\n')+'\n'
+ if size < 0:
+ size = None
+
+ if size is not None:
+ # we need to return maximum byte count of size 'including' the
+ # trailing newline
+ if size == 0:
+ return ''
+
+ size -= 1
+ data = callInReactor(self.stream.readline, '\n', size = size)
+ if len(data) == size:
+ # no newline - try to read one more byte
+ return data + callInReactor(self.stream.readExactly, 1)
+ return data + '\n'
+
+ data = callInReactor(self.stream.readline, '\n')
+ if data: # test that there was data in the stream
+ data += '\n'
+ return data
def readlines(self, hint=None):
# Called in application thread
Index: .cvsignore
===================================================================
RCS file: /cvs/extras/rpms/python-twisted-web2/EL-5/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore 31 Dec 2008 05:51:11 -0000 1.1
+++ .cvsignore 1 Jan 2009 11:18:24 -0000 1.2
@@ -0,0 +1 @@
+TwistedWeb2-0.2.0.tar.bz2
Index: sources
===================================================================
RCS file: /cvs/extras/rpms/python-twisted-web2/EL-5/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sources 31 Dec 2008 05:51:11 -0000 1.1
+++ sources 1 Jan 2009 11:18:24 -0000 1.2
@@ -0,0 +1 @@
+7d6dea006d7f1e004df9f6aad730fbee TwistedWeb2-0.2.0.tar.bz2
- Previous message (by thread): rpms/python-twisted-web2/F-10 python-twisted-web2.spec, NONE, 1.1 twisted-web2_0.2.0-1.1.diff, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
- Next message (by thread): rpms/python-twisted-web2/F-9 python-twisted-web2.spec, NONE, 1.1 twisted-web2_0.2.0-1.1.diff, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list