Unpickling from strings
Fredrik Lundh
fredrik at pythonware.com
Tue Mar 13 18:42:55 EST 2001
Marcin Chady wrote:
> I have pickled an object into a string and saved it in an hidden HTML form
> field, so that I can recover the state when the form is resubmitted.
> However, when the form comes back and I try to unpickle my object I get an
> error saying that the module in which the object's class was originally
> defined is unknown, even though the CGI script which does the unpickling has
> already imported the module!
>
> Has anyone got an idea why it is?
did you pickle classes defined in your main script (aka __main__),
and then failed to unpickle them in another script?
don't do that.
(to solve this, move the classes to a common support module, and
import it into the pickling script)
Cheers /F
More information about the Python-list
mailing list