[TxMt] Re: Creating a global variable via bundle command (using Python)

Baldwin, Dave dave.baldwin at intel.com
Wed Aug 14 08:20:55 UTC 2013


Use YAML to serialize your objected into a string.

require 'yaml'

os.environ['TM_PROJECT_UUID'] = YAML.dump(someobject)

…

someobject  = YAML.load(os.environ['TM_PROJECT_UUID'] )

If someobject is just a composite of standard ruby classes then this will work fine, but if it contains your own class definitions you will need to add a method to code the ivars such as

def to_yaml_properties

%w{ @var1 @var2 }

end

Dave.

From: Michele Pasin <michele.pasin at gmail.com<mailto:michele.pasin at gmail.com>>
Reply-To: TextMate users <textmate at lists.macromates.com<mailto:textmate at lists.macromates.com>>
Date: Wednesday, 14 August 2013 01:41
To: TextMate users <textmate at lists.macromates.com<mailto:textmate at lists.macromates.com>>
Subject: [TxMt] Re: Creating a global variable via bundle command (using Python)

hi again

just a clarification: when I do this

os.environ['TM_PROJECT_UUID'] = someobject

I get an error saying that only strings are accepted as possible values.

is there any other approach for storing a non-string in the environment?

many tx, mikele


On Mon, Aug 12, 2013 at 12:00 PM, Allan Odgaard <mailinglist at textmate.org<mailto:mailinglist at textmate.org>> wrote:
On 11 Aug 2013, at 19:02, Michele Pasin wrote:

[…] each time I send a command, the socket is obviously re-created; I

wondered if I TextMate provides a mechanism to save the 'sock' binding in
the current  environment - so that I can reuse it later within other
commands.

Not per se, but TextMate does give you a TM_DOCUMENT_UUID and TM_PROJECT_UUID variable.

The former is unique per document and the latter is unique per project (window).

You can use these as keys into shared storage (such as files in TMPDIR) to store things that you wish to associate with a single document or project.

Presently though there is no cleanup callback, so if you spawn a server process for a document or project, you should have it shutdown automatically if it hasn’t seen any activity for some amount of time.

_______________________________________________
textmate mailing list
textmate at lists.macromates.com<mailto:textmate at lists.macromates.com>
http://lists.macromates.com/listinfo/textmate



--




--------------------------------
www.michelepasin.org<http://www.michelepasin.org/>

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



More information about the textmate mailing list