python class question

Axel Bock news-and-lists at the-me.de
Thu Jul 25 13:30:45 EDT 2002


Hi folks,

I need an explanation of a piece of code *urgently*, to understand an
error message generated by Zope Python (a pure Python error, I think ...).

Well: I have a class xrml, which wants to access a ZMySQLDA database
connection (all this happens under Zope, but I think my question is pure
Python nonetheless). For this I stole code from another module (ZSQLMethods :-),
and the result looks like this: 

class xrml(SimpleItem.SimpleItem):
	def init_db(self):
		try:
			dbc = getattr(self, connection)
		except: 
			return 'error'
		DB = dbc()

Now I tried to modify the last line as follows: 
		self.DB = dbc()
and getting a very strange error (Error Type: UnpickleableError
Error Value: Cannot pickle <type 'type'> objects).

Now my question is: what the hell am I doing here? Especially what is DB??
connection seems to be equally important, how can I find out what type of
thing this is? A "return self.connection" delivers a
"MySQL_database_connection". Is this a string, or an object?

The code works well (queries and all else) if I use DB instead of self.DB,
but this makes me unable to use DB from other member functions, doesn't
it? (I'm quite a Python newbie i fear ... :-))


Any help would be much appreciated!


Thanks in advance and greetings from Germany, 

		Axel.



More information about the Python-list mailing list