Skip to content

Commit

Permalink
return the interactive namespace for use in third-party libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
florentx committed Sep 19, 2014
1 parent 3de6ba9 commit 7e00be0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Changelog
* New attribute ``Client.context`` to set the default context for
all RPC calls.

* Return the interactive namespace with ``main(interact=False)``.
It helps to integrate with third-party libraries, such as IPython.

* Remove a duplicate ``Logged in as ...`` line in interactive mode.

* Remove the ``search+name_get`` undocumented feature which has
Expand Down
4 changes: 2 additions & 2 deletions erppeek.py
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ def runcode(self, code):
Console().interact('\033[A')


def main():
def main(interact=_interact):
description = ('Inspect data on Odoo objects. Use interactively '
'or query a model (-m) and pass search terms or '
'ids as positional parameters after the options.')
Expand Down Expand Up @@ -1626,7 +1626,7 @@ def main():
if not client.user:
client.connect()
# Enter interactive mode
_interact(global_vars)
return interact(global_vars) if interact else global_vars

if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions tests/test_interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def setUp(self):
mock.patch('erppeek.Client._set_interactive', wraps=erppeek.Client._set_interactive).start()
self.interact = mock.patch('erppeek._interact', wraps=erppeek._interact).start()
self.infunc = mock.patch('code.InteractiveConsole.raw_input').start()
mock.patch('erppeek.main.__defaults__', (self.interact,)).start()

def test_main(self):
env_tuple = ('http://127.0.0.1:8069', 'database', 'usr', None)
Expand Down

0 comments on commit 7e00be0

Please sign in to comment.