Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
transaction
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
transaction
Commits
9aa3a5d5
Commit
9aa3a5d5
authored
Nov 17, 2016
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The transactuon meta-data field, ``extended_info`` has been
renamed to ``extension``.
parent
14bc242c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
15 deletions
+14
-15
CHANGES.rst
CHANGES.rst
+3
-0
transaction/_transaction.py
transaction/_transaction.py
+5
-5
transaction/interfaces.py
transaction/interfaces.py
+2
-6
transaction/tests/test__transaction.py
transaction/tests/test__transaction.py
+4
-4
No files found.
CHANGES.rst
View file @
9aa3a5d5
...
@@ -9,6 +9,9 @@ Changes
...
@@ -9,6 +9,9 @@ Changes
ASCII. It was decided that this would lead to bugs that were hard
ASCII. It was decided that this would lead to bugs that were hard
to test for.
to test for.
Also, the transactuon meta-data field, ``extended_info`` has been
renamed to ``extension``.
2.0.2 (2016-11-13)
2.0.2 (2016-11-13)
------------------
------------------
...
...
transaction/_transaction.py
View file @
9aa3a5d5
...
@@ -101,9 +101,9 @@ class Transaction(object):
...
@@ -101,9 +101,9 @@ class Transaction(object):
# manager as a key, because we can't guess whether the actual
# manager as a key, because we can't guess whether the actual
# resource managers will be safe to use as dict keys.
# resource managers will be safe to use as dict keys.
# The user, description, and exten
ded_info
attributes are accessed
# The user, description, and exten
sion
attributes are accessed
# directly by storages, leading underscore notwithstanding.
# directly by storages, leading underscore notwithstanding.
self
.
exten
ded_info
=
{}
self
.
exten
sion
=
{}
self
.
log
=
_makeLogger
()
self
.
log
=
_makeLogger
()
self
.
log
.
debug
(
"new transaction"
)
self
.
log
.
debug
(
"new transaction"
)
...
@@ -123,11 +123,11 @@ class Transaction(object):
...
@@ -123,11 +123,11 @@ class Transaction(object):
def
_extension
(
self
):
def
_extension
(
self
):
# for backward compatibility, since most clients used this
# for backward compatibility, since most clients used this
# absent any formal API.
# absent any formal API.
return
self
.
exten
ded_info
return
self
.
exten
sion
@
_extension
.
setter
@
_extension
.
setter
def
_extension
(
self
,
v
):
def
_extension
(
self
,
v
):
self
.
exten
ded_info
=
v
self
.
exten
sion
=
v
@
property
@
property
def
user
(
self
):
def
user
(
self
):
...
@@ -554,7 +554,7 @@ class Transaction(object):
...
@@ -554,7 +554,7 @@ class Transaction(object):
def
setExtendedInfo
(
self
,
name
,
value
):
def
setExtendedInfo
(
self
,
name
,
value
):
""" See ITransaction.
""" See ITransaction.
"""
"""
self
.
exten
ded_info
[
name
+
u''
]
=
value
# + u'' to make sure it's unicod
e
self
.
exten
sion
[
name
]
=
valu
e
# TODO: We need a better name for the adapters.
# TODO: We need a better name for the adapters.
...
...
transaction/interfaces.py
View file @
9aa3a5d5
...
@@ -125,12 +125,8 @@ class ITransaction(Interface):
...
@@ -125,12 +125,8 @@ class ITransaction(Interface):
raise an exception, or truncate the value).
raise an exception, or truncate the value).
"""
)
"""
)
extended_info
=
Attribute
(
extension
=
Attribute
(
"""A dictionary containing application-defined metadata.
"A dictionary containing application-defined metadata."
)
Keys must be text (unicode). Values must be simple values
serializable with json or pickle (not instances).
"""
)
def
commit
():
def
commit
():
"""Finalize the transaction.
"""Finalize the transaction.
...
...
transaction/tests/test__transaction.py
View file @
9aa3a5d5
...
@@ -76,8 +76,8 @@ class TransactionTests(unittest.TestCase):
...
@@ -76,8 +76,8 @@ class TransactionTests(unittest.TestCase):
self
.
assertEqual
(
txn
.
_resources
,
[])
self
.
assertEqual
(
txn
.
_resources
,
[])
self
.
assertEqual
(
txn
.
_adapters
,
{})
self
.
assertEqual
(
txn
.
_adapters
,
{})
self
.
assertEqual
(
txn
.
_voted
,
{})
self
.
assertEqual
(
txn
.
_voted
,
{})
self
.
assertEqual
(
txn
.
exten
ded_info
,
{})
self
.
assertEqual
(
txn
.
exten
sion
,
{})
self
.
assertTrue
(
txn
.
_extension
is
txn
.
exten
ded_info
)
# legacy
self
.
assertTrue
(
txn
.
_extension
is
txn
.
exten
sion
)
# legacy
self
.
assertTrue
(
txn
.
log
is
logger
)
self
.
assertTrue
(
txn
.
log
is
logger
)
self
.
assertEqual
(
len
(
logger
.
_log
),
1
)
self
.
assertEqual
(
len
(
logger
.
_log
),
1
)
self
.
assertEqual
(
logger
.
_log
[
0
][
0
],
'debug'
)
self
.
assertEqual
(
logger
.
_log
[
0
][
0
],
'debug'
)
...
@@ -1019,7 +1019,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -1019,7 +1019,7 @@ class TransactionTests(unittest.TestCase):
def
test_setExtendedInfo_single
(
self
):
def
test_setExtendedInfo_single
(
self
):
txn
=
self
.
_makeOne
()
txn
=
self
.
_makeOne
()
txn
.
setExtendedInfo
(
'frob'
,
'qux'
)
txn
.
setExtendedInfo
(
'frob'
,
'qux'
)
self
.
assertEqual
(
txn
.
exten
ded_info
,
{
u'frob'
:
'qux'
})
self
.
assertEqual
(
txn
.
exten
sion
,
{
u'frob'
:
'qux'
})
self
.
assertTrue
(
txn
.
_extension
is
txn
.
_extension
)
# legacy
self
.
assertTrue
(
txn
.
_extension
is
txn
.
_extension
)
# legacy
def
test_setExtendedInfo_multiple
(
self
):
def
test_setExtendedInfo_multiple
(
self
):
...
@@ -1035,7 +1035,7 @@ class TransactionTests(unittest.TestCase):
...
@@ -1035,7 +1035,7 @@ class TransactionTests(unittest.TestCase):
txn
=
self
.
_makeOne
()
txn
=
self
.
_makeOne
()
txn
.
_extension
=
dict
(
baz
=
'spam'
)
txn
.
_extension
=
dict
(
baz
=
'spam'
)
txn
.
setExtendedInfo
(
'frob'
,
'qux'
)
txn
.
setExtendedInfo
(
'frob'
,
'qux'
)
self
.
assertEqual
(
txn
.
exten
ded_info
,
{
u'frob'
:
'qux'
,
'baz'
:
'spam'
})
self
.
assertEqual
(
txn
.
exten
sion
,
{
u'frob'
:
'qux'
,
'baz'
:
'spam'
})
def
test_data
(
self
):
def
test_data
(
self
):
txn
=
self
.
_makeOne
()
txn
=
self
.
_makeOne
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment