[Repoze-checkins] r1263 - in repoze.monty/trunk: . repoze/monty
Chris McDonough
chrism at agendaless.com
Thu Jul 10 12:10:44 EDT 2008
Author: Chris McDonough <chrism at agendaless.com>
Date: Thu Jul 10 12:10:43 2008
New Revision: 1263
Log:
Pass POST data to marshaller explicitly.
Modified:
repoze.monty/trunk/LICENSE.txt
repoze.monty/trunk/repoze/monty/__init__.py
repoze.monty/trunk/repoze/monty/tests.py
repoze.monty/trunk/setup.py
Modified: repoze.monty/trunk/LICENSE.txt
==============================================================================
--- repoze.monty/trunk/LICENSE.txt (original)
+++ repoze.monty/trunk/LICENSE.txt Thu Jul 10 12:10:43 2008
@@ -1,41 +1,54 @@
-License
+Zope Public License (ZPL) Version 2.1
+-------------------------------------
- A copyright notice accompanies this license document that identifies
- the copyright holders.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- 1. Redistributions in source code must retain the accompanying
- copyright notice, this list of conditions, and the following
- disclaimer.
-
- 2. Redistributions in binary form must reproduce the accompanying
- copyright notice, this list of conditions, and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
- 3. Names of the copyright holders must not be used to endorse or
- promote products derived from this software without prior
- written permission from the copyright holders.
-
- 4. If any files are modified, you must cause the modified files to
- carry prominent notices stating that you changed the files and
- the date of any change.
-
- Disclaimer
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND
- ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
+A copyright notice accompanies this license document that
+identifies the copyright holders.
+This license has been certified as open source. It has also
+been designated as GPL compatible by the Free Software
+Foundation (FSF).
+
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the
+following conditions are met:
+
+1. Redistributions in source code must retain the
+ accompanying copyright notice, this list of conditions,
+ and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the accompanying
+ copyright notice, this list of conditions, and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+3. Names of the copyright holders must not be used to
+ endorse or promote products derived from this software
+ without prior written permission from the copyright
+ holders.
+
+4. The right to distribute this software or to use it for
+ any purpose does not give you the right to use
+ Servicemarks (sm) or Trademarks (tm) of the copyright
+ holders. Use of them is covered by separate agreement
+ with the copyright holders.
+
+5. If any files are modified, you must cause the modified
+ files to carry prominent notices stating that you changed
+ the files and the date of any change.
+
+Disclaimer
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS''
+ AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
+ NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ NO EVENT SHALL THE COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGE.
Modified: repoze.monty/trunk/repoze/monty/__init__.py
==============================================================================
--- repoze.monty/trunk/repoze/monty/__init__.py (original)
+++ repoze.monty/trunk/repoze/monty/__init__.py Thu Jul 10 12:10:43 2008
@@ -1,3 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
from cgi import FieldStorage
import re
@@ -154,8 +167,9 @@
get_converter = type_converters.get
class FieldMarshaller:
- def __init__(self, environ):
+ def __init__(self, environ, fp):
self._environ = environ
+ self.fp = fp
self.method = self._environ.get('REQUEST_METHOD', 'GET')
self.charsets = ['utf-8']
self.form = {}
@@ -165,7 +179,7 @@
if self.method not in ('GET', 'HEAD'):
# Process self.form if not a GET request.
- fp = self._environ['wsgi.input']
+ fp = self.fp
if self.method == 'POST':
content_type = self._environ.get('CONTENT_TYPE')
if content_type and not (
@@ -441,6 +455,6 @@
elif not val in item:
item.append(val)
-def marshal(environ):
- marshaller = FieldMarshaller(environ)
+def marshal(environ, fp):
+ marshaller = FieldMarshaller(environ, fp)
return marshaller.processInputs()
Modified: repoze.monty/trunk/repoze/monty/tests.py
==============================================================================
--- repoze.monty/trunk/repoze/monty/tests.py (original)
+++ repoze.monty/trunk/repoze/monty/tests.py Thu Jul 10 12:10:43 2008
@@ -7,7 +7,7 @@
def test_empty_GET(self):
f = self._getFUT()
- self.assertEqual(f({}), {})
+ self.assertEqual(f({}, None), {})
def _makeEnviron(self, kw=None):
if kw is None:
@@ -36,7 +36,7 @@
('password', 'password')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['login'], u'login')
self.assertEqual(result['password'], u'password')
@@ -44,40 +44,40 @@
fields = [('myval:float', '1.0')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], 1.0)
def test_multipart_form_POST_floatconvert_fail(self):
fields = [('myval:float', 'None')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- self.assertRaises(ValueError, f, environ)
+ self.assertRaises(ValueError, f, environ, environ['wsgi.input'])
def test_multipart_form_POST_intconvert_succeed(self):
fields = [('myval:int', '1')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], 1)
def test_multipart_form_POST_intconvert_fail(self):
fields = [('myval:int', 'None')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- self.assertRaises(ValueError, f, environ)
+ self.assertRaises(ValueError, f, environ, environ['wsgi.input'])
def test_multipart_form_POST_listconvert_succeed(self):
fields = [('myval:list', '1'), ('myval:list', '2')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], ['1', '2'])
def test_multipart_form_POST_tupleconvert_succeed(self):
fields = [('myval:tuple', '1'), ('myval:tuple', '2')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], ('1', '2'))
def test_multipart_form_POST_longconvert_succeed(self):
@@ -85,75 +85,75 @@
fields = [('myval:long', str(sys.maxint+1))]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], sys.maxint +1 )
def test_multipart_form_POST_longconvert_fail(self):
fields = [('myval:long', 'None')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- self.assertRaises(ValueError, f, environ)
+ self.assertRaises(ValueError, f, environ, environ['wsgi.input'])
def test_multipart_form_POST_stringconvert_succeed(self):
fields = [('myval:string', '1')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], '1')
def test_multipart_form_POST_requiredconvert_succeed(self):
fields = [('myval:required', '1')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], '1')
def test_multipart_form_POST_requiredconvert_fail(self):
fields = [('myval:required', '')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- self.assertRaises(ValueError, f, environ)
+ self.assertRaises(ValueError, f, environ, environ['wsgi.input'])
def test_multipart_form_POST_tokensconvert_succeed(self):
fields = [('myval:tokens', 'abc def')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], ['abc', 'def'])
def test_multipart_form_POST_linesconvert_succeed(self):
fields = [('myval:tokens', 'abc\ndef')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], ['abc', 'def'])
def test_multipart_form_POST_textconvert_succeed(self):
fields = [('myval:text', 'abc\r\ndef')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], 'abc\ndef')
def test_multipart_form_POST_boolconvert_succeed(self):
fields = [('myval:boolean', '1')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], True)
def test_multipart_form_POST_multiconvert_succeed(self):
fields = [('myval:list:int', '1'), ('myval:list:int', '2')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['myval'], [1, 2])
def test_multipart_form_POST_recordconvert_succeed(self):
fields = [('person.fname:record', 'chris'), ('person.lname:record','m')]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
self.assertEqual(result['person']['fname'], u'chris')
self.assertEqual(result['person']['lname'], u'm')
@@ -164,7 +164,7 @@
]
environ = self._makeMultipartEnviron(fields)
f = self._getFUT()
- result = f(environ)
+ result = f(environ, environ['wsgi.input'])
people = result['people']
self.assertEqual(len(people), 2)
chris = people[0]
Modified: repoze.monty/trunk/setup.py
==============================================================================
--- repoze.monty/trunk/setup.py (original)
+++ repoze.monty/trunk/setup.py Thu Jul 10 12:10:43 2008
@@ -41,7 +41,7 @@
author="Agendaless Consulting",
author_email="repoze-dev at lists.repoze.org",
url="http://www.repoze.org",
- license="BSD-derived (http://www.repoze.org/LICENSE.txt)",
+ license='ZPL 2.1',
packages=find_packages(),
include_package_data=True,
namespace_packages=['repoze'],
More information about the Repoze-checkins
mailing list