Skip to content

Commit

Permalink
The transactuon meta-data field, extended_info has been
Browse files Browse the repository at this point in the history
renamed to ``extension``.
  • Loading branch information
Jim Fulton committed Nov 17, 2016
1 parent 14bc242 commit 9aa3a5d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,9 @@ Changes
ASCII. It was decided that this would lead to bugs that were hard
to test for.

Also, the transactuon meta-data field, ``extended_info`` has been
renamed to ``extension``.

2.0.2 (2016-11-13)
------------------

Expand Down
10 changes: 5 additions & 5 deletions transaction/_transaction.py
Expand Up @@ -101,9 +101,9 @@ def __init__(self, synchronizers=None, manager=None):
# 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")
Expand All @@ -123,11 +123,11 @@ def __init__(self, synchronizers=None, manager=None):
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):
Expand Down Expand Up @@ -554,7 +554,7 @@ def setUser(self, user_name, path=u"/"):
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.
Expand Down
8 changes: 2 additions & 6 deletions transaction/interfaces.py
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions transaction/tests/test__transaction.py
Expand Up @@ -76,8 +76,8 @@ def test_ctor_defaults(self):
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')
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def test_user_bytes(self):
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):
Expand All @@ -1035,7 +1035,7 @@ def test__extension_settable(self):
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()
Expand Down

0 comments on commit 9aa3a5d

Please sign in to comment.