apologies for resurrecting this very old thread, but I'm kind of stuck
In short, I'm developing a bundle for sending messages to the Extempore
which should happen via a TCP socket connection.
Ideally, I'd like to create the following commands:
a) start the server [done, see
b) set up a reusable socket connection object
c) evaluate expressions by sending them to the server using the connection
I've set up environment variables in Textmate to hold my connection
settings; also, I've created a variable called EXTEMPORE_CONNECTION which
in theory should keep the pickled version of my server socket.
Here's my Python command:
# -*- coding: utf-8 -*-
import os, socket
xtm_host = str(os.environ.get('EXTEMPORE_HOST', "127.0.0.1"))
xtm_port = int(os.environ.get('EXTEMPORE_PORT', 7099))
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = xtm_host
PORT = xtm_port
data = sock.recv(1024)
print(data) # welcome message, works.
os.environ['EXTEMPORE_CONNECTION'] = pickle.dumps(sock, -1) # *fails*
The problem is, Python's pickle doesn't support all kinds of objects, and
sockets are among those (see
So I wonder if there's another way of approaching the problem; or, if by
any chance, the same approach done via another language (eg Ruby) would not
encounter any limitation..
Thanks in advance for the help,
On 14 August 2013 at 09:55, Allan Odgaard <mailinglist(a)textmate.org> wrote:
On 14 Aug 2013, at 2:41, Michele Pasin wrote:
[…] when I do this
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
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.
textmate mailing list