ZODB and Boa
Diez B. Roggisch
deetsNOSPAM at web.de
Thu Oct 14 05:24:41 EDT 2004
Hi,
> Excuse my newbiehood/ignorance, I'm not sure I understand your reply.
> Would you please elaborate?
I'll try.
>From your first post:
>>> <persistent broken __main__.Calendar instance
As you can see, ZODB tries to instanciate a class Calendar, that is supposed
to be defined in the python file that is executed by the interpreter - thus
resulting in the __name__ == "__main__", and no module-name prefixed to the
class name "Calendar".
But I doubt that Calendar is defined there, in fact your seconds post code
showed there is only some gui-stuff - instead it will be located in some
module, maybe the "calFrame1" you imported, or in module "code" from your
previous post. I assume the latter for now.
Now when you run the code that first created and stored Calendar objects,
you did run it directly, resulting in the fully qualified classname beeing
__main__.Calendar
But now running your app, you want it to be code.Calendar. Unfortunately,
there is no way (or at least not known to me) to alter the class name
after it has been stored.
So this might help: Delete the ZODB FileStorage, and then rerun your
program. It will work.
Then look at the module "code". Don't use it as you do now - its generally
not a good idea to let code be executed in a modules rump when its
imported. Instead, rewrite it like this:
class Calendar:
....
def init():
# do the initialization stuff you did before in the rump here
if __name__ == "__main__":
# if executed directly, reimport ourselves under the desired name, and
then run init
import code
code.init()
That should then make things work in both ways.
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list