Commit b13ef04e authored by Jim Fulton's avatar Jim Fulton Committed by GitHub

Merge pull request #33 from zopefoundation/extended_info-to-extension

extended-info -> extension

I'll make the transaction release and then I'll push an update to the ZODB PR that works with the change.
parents 14bc242c 49e42e76
......@@ -9,6 +9,9 @@ Changes
ASCII. It was decided that this would lead to bugs that were hard
to test for.
Also, the transaction meta-data field, ``extended_info`` has been
renamed to ``extension``.
2.0.2 (2016-11-13)
------------------
......
......@@ -101,9 +101,9 @@ class Transaction(object):
# manager as a key, because we can't guess whether the actual
# resource managers will be safe to use as dict keys.
# The user, description, and extended_info attributes are accessed
# The user, description, and extension attributes are accessed
# directly by storages, leading underscore notwithstanding.
self.extended_info = {}
self.extension = {}
self.log = _makeLogger()
self.log.debug("new transaction")
......@@ -123,11 +123,11 @@ class Transaction(object):
def _extension(self):
# for backward compatibility, since most clients used this
# absent any formal API.
return self.extended_info
return self.extension
@_extension.setter
def _extension(self, v):
self.extended_info = v
self.extension = v
@property
def user(self):
......@@ -554,7 +554,7 @@ class Transaction(object):
def setExtendedInfo(self, name, value):
""" See ITransaction.
"""
self.extended_info[name + u''] = value # + u'' to make sure it's unicode
self.extension[name] = value
# TODO: We need a better name for the adapters.
......
......@@ -125,12 +125,8 @@ class ITransaction(Interface):
raise an exception, or truncate the value).
""")
extended_info = Attribute(
"""A dictionary containing application-defined metadata.
Keys must be text (unicode). Values must be simple values
serializable with json or pickle (not instances).
""")
extension = Attribute(
"A dictionary containing application-defined metadata.")
def commit():
"""Finalize the transaction.
......
......@@ -76,8 +76,8 @@ class TransactionTests(unittest.TestCase):
self.assertEqual(txn._resources, [])
self.assertEqual(txn._adapters, {})
self.assertEqual(txn._voted, {})
self.assertEqual(txn.extended_info, {})
self.assertTrue(txn._extension is txn.extended_info) # legacy
self.assertEqual(txn.extension, {})
self.assertTrue(txn._extension is txn.extension) # legacy
self.assertTrue(txn.log is logger)
self.assertEqual(len(logger._log), 1)
self.assertEqual(logger._log[0][0], 'debug')
......@@ -1019,7 +1019,7 @@ class TransactionTests(unittest.TestCase):
def test_setExtendedInfo_single(self):
txn = self._makeOne()
txn.setExtendedInfo('frob', 'qux')
self.assertEqual(txn.extended_info, {u'frob': 'qux'})
self.assertEqual(txn.extension, {u'frob': 'qux'})
self.assertTrue(txn._extension is txn._extension) # legacy
def test_setExtendedInfo_multiple(self):
......@@ -1035,7 +1035,7 @@ class TransactionTests(unittest.TestCase):
txn = self._makeOne()
txn._extension = dict(baz='spam')
txn.setExtendedInfo('frob', 'qux')
self.assertEqual(txn.extended_info, {u'frob': 'qux', 'baz': 'spam'})
self.assertEqual(txn.extension, {u'frob': 'qux', 'baz': 'spam'})
def test_data(self):
txn = self._makeOne()
......
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