[TxMt] Re: Creating a global variable via bundle command (using Python)
Allan Odgaard
mailinglist at textmate.org
Wed Aug 14 08:55:42 UTC 2013
On 14 Aug 2013, at 2:41, Michele Pasin wrote:
> […] when I do this
> os.environ['TM_PROJECT_UUID'] = someobject
> I get an error […]
You can’t assign to environment variables. The variable is to be used
as a key into a database, in the simplest case something like:
uuid = os.environ['TM_PROJECT_UUID'] # Same when window is the same
file = os.path.join(tempfile.gettempdir(), "tm_«your_command»_" +
uuid + ".pickle")
pickle.dump(someobject, file)
For each invocation of your command, ‘uuid’ will be the same, as
long as it’s called for the same (project) window.
Your command would start by testing if ‘file’ already exists, and if
so, read ‘someobj’ by unpickling it.
More information about the textmate
mailing list