Tkinter, pickle (or shelve) and marshal

Grzegorz Dostatni grzegorz at ugrad.cs.ualberta.ca
Sun Nov 4 12:23:28 CET 2001


Cheers!


How do I detect when an object is being Pickled (or just before?).
Read below for an explanation (WHY ???)


In short. I want to take a current graphical state of an application (or
perhaps only a part of it) and pickle it (usually to database, but just
plain pickle will suffice).  I may also need to pickle code objects  -
hence marshal.

I know that normally that will not work.  Widgets are part of the TkApp
object that cannot be pickled.  However if I can detect that an object is
being pickled I can save complete widget information, dynamically delete
all  references to runtime tkApp object (or create a new class that will
do so) and save that "cut down" version of my widgets.  That should work.

I can write a module that will modify Tkinter in memory to smoothly add
that functionality (I've done similar things before ;-) - to make it
easier on the less experienced Python programmers).  I need to be able to
detect when an object is being pickled.  I could hack it as well by
binding myself to the pickle module in memory as well.  (what I mean is
that I import pickle module, import picklewrap module that renames all the
functions in pickle and adds my own wrappers to the pickle module - all
that is done in memory, and If I do it right - the program knows no
difference ).

As an added incentive my  project is going to end up under GPL. The real
project is not going to be all that usefull to most people, but some parts
of it are going to be quite interesting.  The ability to create a
graphical application from a definition in a database will be another.  As
well as a Tree widget that displays Database info and allows to edit
Python code within, etc, etc.

I am looking  for a beautifull, Pythonic way to solve this ;-)

Grzegorz

_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_

Some family trees bear an enormous crop of nuts.
		Wayne H.

Drawing on my fine command of language, I said nothing.
               	*Anonymous




More information about the Python-list mailing list