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

session() does not restore previous engine if fails #211

Closed
dm-logv opened this Issue Sep 13, 2018 · 1 comment

Comments

2 participants
@dm-logv
Copy link

dm-logv commented Sep 13, 2018

When with redmine.session() fails redminelib does not restore previous used engine.

Example:

rm = redminelib.Redmine('https://redmine.intranet')

# Original engine
print(rm.engine)

try:
    with rm.session(impersonate='william_gates'):
        # Masked engine
        print(rm.engine)
        # Some fails
        rm.issue.create(project_id='test', subject='foo')
except redminelib.exceptions.ImpersonateError as e:
    print(e)

# Should be original engine again?
print(rm.engine) 

Output:

<redminelib.engines.sync.SyncEngine object at 0x03D1B9F0>
<redminelib.engines.sync.SyncEngine object at 0x040EBD10>
Impersonate login provided doesn't exist or isn't active
<redminelib.engines.sync.SyncEngine object at 0x040EBD10>

dm-logv added a commit to dm-logv/python-redmine that referenced this issue Sep 13, 2018

issue maxtepkeev#211
Add exception handling for a `session()` and restore original engine if it fails

@maxtepkeev maxtepkeev self-assigned this Sep 13, 2018

@maxtepkeev maxtepkeev added the bug label Sep 13, 2018

@maxtepkeev

This comment has been minimized.

Copy link
Owner

maxtepkeev commented Sep 13, 2018

Fixed via #212, thanks @dm-logv

@maxtepkeev maxtepkeev closed this Sep 13, 2018

maxtepkeev added a commit that referenced this issue Jan 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment