New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an ExecuteLastObjectDataManager that attempts to execute after ot… #11
Conversation
…her ObjectDataManagers
src/nti/transactions/transactions.py
Outdated
@@ -237,6 +253,16 @@ def do(*args, **kwargs): | |||
transaction.get().join(result) | |||
return result | |||
|
|||
def do_last(*args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not use the word "last", here or in the class? That implies promises we can't keep, and it makes no sense if this function/class is used more than once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommendations? I'm stumped :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OrderedNearEndObjectDataManager
and do_near_end
? (I suppose even NearLast
would get the point across.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with either of those. I was hoping the comments would provide the caveat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if you read the docstrings. That doesn't help someone just reading the code where this is used.
src/nti/transactions/transactions.py
Outdated
execute *after* all other DataManagers have had their say. | ||
See :class:`ObjectDataManager` for the possible arguments. | ||
""" | ||
result = ExecuteLastObjectDataManager(*args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than reimplementing this, what about something like this:
def do(*args, **kwargs):
klass = kwargs.pop('datamanager_class', ObjectDataManager) # new argument
result = klass(*args, **kwargs)
... # as before
def do_XXX(*args, **kwargs):
kwargs['datamanager_class'] = XXXDataManager
return do(*args, **kwargs)
out of curiosity how does this work with the single phase commit transactions in the zope transaction manager? IIRC those get sorted to the end by the transaction manager (i've seen this in certain implementations of sqlalchemy). Does this sort before or after those? |
The zope transaction manager doesn't have a "single phase commit transaction" so I'm not sure what you mean. It only supports two-phase commit. Individual data managers may or may not do something useful during all of those phases. |
Sorry it was the specific sqlalchemy transaction datamanager I was remembering. It tries to sort single phase committers to the end. |
|
2 similar comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor formatting issues.
from ..transactions import TransactionLoop | ||
from ..interfaces import CommitFailedError | ||
from ..interfaces import AbortFailedError | ||
from nti.transactions.interfaces import CommitFailedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we preferred absolute imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't, they make refactoring harder.
manager_post = do_near_end(call=test_call, args=(10,)) | ||
manager3 = do(call=test_call, args=(2,)) | ||
transaction.commit() | ||
assert_that(results, contains(0,1,2,10)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces between commas, please.
2 similar comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a note to CHANGES.rst? And add ..versionadded:: 1.1
lines to the end of the docstrings for the new objects?
Sorry, I should have mentioned that earlier.
…her ObjectDataManagers #10 @papachoco @jamadden