Pickling: how do I ask an intelligent question?

Gustin Kiffney kiffney at my-deja.com
Wed Sep 22 18:39:04 EDT 1999


I'm a first-time caller to comp.lang.python (except for one gasp of
amazement when like Cortez with wild surmise from a peak in Darien
glimpsed the wide Pythonic ocean, etc).  I've got simple Perl-like CGI
stuff (parse files, do system stuff) working well, but I still ain't
sure about the higher abstractions in Python.  For example, I looked
at some of Sam Rushing's code and how he used hasattr, getattr
to kind of make his own program a 'jump table' to handle whatever
commands a chat client might send - simply amazing, the kind of stuff
I've been trying to figure out how to do for quite a while in lesser
languages ...

OK, obligatory ritual newsgroup flattering done, now comes the crude
demand for help from this python-understanding-poor panhandler. I'm
trying to pull some Windows-only ODBC data off a NT machine and get it
over to the Linux web server using pieces of the medusa package
(asynchat, monitor, etc.).  The scheme is to construct an SQL sentence
and a few parameters via Python CGI on Linux, send it to the NT
machine's Python listening on a socket, have the Python interpreter on
the NT
machine parse this out and give back the data set to Linux - sort of a
poor man's SQL server system for some Foxpro/Access data (oops, I guess
the dirty underlayer of this system is showing now).

At first I thought of working out 'expect' like scripts - Linux Python
snds some ODBC setup data, connection name, etc, the sql string -
and the NT python listener does a bunch of parsing, looking for
terminators, and the like -

but in looking at the pickle module it seems that I could somehow
package up an 'object' and send all that to the NT python server, who
could then unravel it and send back pickled results.  This seems neater
and more elegant, but maybe that's because I don't have any notion
about how you really do that.  I actually don't understand what an
'object' is yet - some innate stupidity about abstractions - and I
can't figure out how I'd construct this thing.  I mean, I can get
pickle to pickle a list or whatever to a file, and get it back out,
but how would you
construct and pickle a collection of information like named parameters,
strings, data tuples, etc and then USE it on the other side, modify it,
fill in the data,and send it back?  I KNOW this is obvious to the
enlightened but one simple code example is worth a million jargon terms
to abstraction-impaired ex-assembly-programmers like me.

And could you actually send and use code - in case the other machine
didn't have a module that described a type your first machine was
sending? How do you do that?

standard protestations about how hard I've looked in Dejanews,
www.python.org, starship python, etc can be filled in here.  {Actually
I find that the search functions on starship python simply don't
work when I use them.  can a cgi script sense my lack of enlightenment
and refuse to cough up answers that I might not be ready for?}


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list