Namespaces for embedding #1140

Merged
merged 7 commits into from Dec 12, 2011

Conversation

Projects
None yet
3 participants
@takluyver
Member

takluyver commented Dec 10, 2011

This should fix the embedding problem in #1136.

One additional complexity: if you specify only one of user_ns or user_module when instantiating the embedded shell, they are hooked up so that you have a single namespace (i.e. ip.user_ns is ip.user_global_ns). So, the logic at activation time to auto-detect the module and local namespace will only kick in if neither were specified at instantiation.

You should still be able to pass local_ns or module at activation to override them separately.

@g2p

This comment has been minimized.

Show comment
Hide comment
@g2p

g2p Dec 10, 2011

Contributor

Thank you. Both my simple example and the scrapy shell are working well.

Contributor

g2p commented Dec 10, 2011

Thank you. Both my simple example and the scrapy shell are working well.

+ pass
+ warnings.warn("global_ns is deprecated, use module instead.", DeprecationWarning)
+ module = DummyMod()
+ module.__dict__ = global_ns

This comment has been minimized.

@minrk

minrk Dec 11, 2011

Member

Thanks, I think this is the main thing we need to preserve.

@minrk

minrk Dec 11, 2011

Member

Thanks, I think this is the main thing we need to preserve.

@minrk

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Dec 11, 2011

Member

Terrific, thanks for taking care of it. Do we / can we have simple tests for some of the basic cases?

Member

minrk commented Dec 11, 2011

Terrific, thanks for taking care of it. Do we / can we have simple tests for some of the basic cases?

@takluyver

This comment has been minimized.

Show comment
Hide comment
@takluyver

takluyver Dec 11, 2011

Member

I'm not quite sure how to automate tests for embedding, but I can tidy up a couple of test scripts and add them in docs/examples to run manually if that's sufficient.

Member

takluyver commented Dec 11, 2011

I'm not quite sure how to automate tests for embedding, but I can tidy up a couple of test scripts and add them in docs/examples to run manually if that's sufficient.

@takluyver

This comment has been minimized.

Show comment
Hide comment
@takluyver

takluyver Dec 11, 2011

Member

Added some manual test scripts.

Member

takluyver commented Dec 11, 2011

Added some manual test scripts.

@minrk

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Dec 12, 2011

Member

Nice. Manual tests look good, and I checked embedded shells in currently released sympy and django, both of which appear to work happily (at least they don't raise) with your changes. If you think this is good to go, go ahead and merge.

Member

minrk commented Dec 12, 2011

Nice. Manual tests look good, and I checked embedded shells in currently released sympy and django, both of which appear to work happily (at least they don't raise) with your changes. If you think this is good to go, go ahead and merge.

@takluyver takluyver merged commit feb3b24 into ipython:master Dec 12, 2011

@takluyver

This comment has been minimized.

Show comment
Hide comment
@takluyver

takluyver Dec 12, 2011

Member

Thanks, merged.

Member

takluyver commented Dec 12, 2011

Thanks, merged.

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