Commit 28548bd8 authored by Tres Seaver's avatar Tres Seaver

- Resolve Collector #89 by making repr of record eval'able as a dict.

parent 0b109961
...@@ -75,6 +75,9 @@ Zope Changes ...@@ -75,6 +75,9 @@ Zope Changes
Bugs: Bugs:
- Made repr of an HTTPRequest.record eval'able as a dict (Collector
#89).
- Fixed bug #144: Upload button on dtml, py scripts, images, files and - Fixed bug #144: Upload button on dtml, py scripts, images, files and
pts now raises an error if the file is not specified rather than pts now raises an error if the file is not specified rather than
clearing the source. clearing the source.
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.66 $'[11:-2] __version__='$Revision: 1.67 $'[11:-2]
import re, sys, os, urllib, time, random, cgi, codecs import re, sys, os, urllib, time, random, cgi, codecs
from BaseRequest import BaseRequest from BaseRequest import BaseRequest
...@@ -1128,10 +1128,11 @@ class record: ...@@ -1128,10 +1128,11 @@ class record:
return ", ".join(map(lambda item: "%s: %s" % item, L1)) return ", ".join(map(lambda item: "%s: %s" % item, L1))
def __repr__(self): def __repr__(self):
#return repr( self.__dict__ )
L1 = self.__dict__.items() L1 = self.__dict__.items()
L1.sort() L1.sort()
return ', '.join( return '{%s}' % ', '.join(
map(lambda item: "%s: %s" % (item[0], repr(item[1])), L1)) map(lambda item: "'%s': %s" % (item[0], repr(item[1])), L1))
# Flags # Flags
SEQUENCE=1 SEQUENCE=1
......
import unittest
class RecordTests( unittest.TestCase ):
def test_repr( self ):
from ZPublisher.HTTPRequest import record
record = record()
record.a = 1
record.b = 'foo'
r = repr( record )
d = eval( r )
self.assertEqual( d, record.__dict__ )
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(RecordTests, 'test'))
return suite
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment