[Zope-dev] Persistence bug?

Paul Prescod paul@prescod.net
Fri, 27 Aug 1999 18:25:38 -0400


Jim Fulton wrote:
> 
> How did you execue this? What error did you get?

Ironically, I got it to work fine As Long As I didn't close the
connection. 

External method:

import Globals

def doit( state="Texas", city="Dallas"):
	connection = Globals.DB.open()

	connection.root()["myobj"]="abc" 
# causes crash: connection.close()
	return "blah"

If I don't comment out that line:

Traceback (innermost last):
  File C:\temp\mywebsite\lib\python\ZPublisher\Publish.py, line 209, in
publish_module
  File C:\temp\mywebsite\lib\python\ZPublisher\Publish.py, line 179, in
publish
  File C:\temp\mywebsite\lib\python\Zope\__init__.py, line 199, in
zpublisher_exception_hook
    (Object: ApplicationDefaultPermissions)
  File C:\temp\mywebsite\lib\python\ZPublisher\Publish.py, line 169, in
publish
  File C:\temp\mywebsite\lib\python\ZODB\Transaction.py, line 236, in
commit
  File C:\temp\mywebsite\lib\python\ZODB\Connection.py, line 459, in
tpc_begin
Error Type: AttributeError
Error Value: 'None' object has no attribute 'tpc_begin'

----

I also had an unrelated problem that I can't reporduce:

Zope was trying to unpickle an instance of a class that I had defiend in
the external method  and then deleted. I  tried to define it again but
it didn't work. Maybe the problem is not that I deleted it but rather
that I defined the class in an extension. Extensions aren't imported in
the "standard way". They are "exec"ed on demand, right?

The error message (on Zope startup) was:

SystemError: Failed to import class PersistString from module __main__

I figured out how to work around this while I was writing this message.
I defined the classes in __main__

Maybe Zope should disallow you from persisting classes defined in
__main__ if that's a problem. That would help others avoid my problem.

 Paul Prescod