fengzhao / fengzhao/pyv8

Unable to create different context

未关闭
#167 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
auto-migrated OpSys-All Priority-Medium Type-Enhancement
主要语言
Python
星标
0
派生
0
PR 合并指标
30 天内没有已合并 PR

描述

```
I’m using PyV8 as a base for my Sublime Text plugins. I’ve successfully
used PyV8 on my Emmet plugin, but now I’m creating a new plugin and have
issues with JS context.

Each plugin creates it’s own JSContext instance that should keep data and
exist during plugin lifetime. Context is initiated as follows:

```

self._ctx = PyV8.JSContext()
self._ctx.enter()
self._ctx.eval('...JS source code...')

```

The problem is that PyV8 seems to have just one JS context which is shared
across plugins.

For example, if Sublime Text loads plugin A and then B, I can access JS methods
of B plugin but not A (error is: `AttributeError: '[object global]' object has
no attribute 'XXX'`). If I explicitly reload plugin A (e.g. re-initiate it) I
can access methods of A but not B.

Here’s how JSContext is used in plugin:
https://github.com/sergeche/emmet-sublime/blob/master/emmet/context.py#L170
```

Original issue reported on code.google.com by `serge....@gmail.com` on 22 Mar 2013 at 5:34

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。