[Zope] Zope Python OO

Patrick W. Fraley pf@comsulting.de
24 Apr 2003 16:10:19 +0200


Hi List,

I am working on a project which will make use of a lot of python code. 
And I just ran accros a problem trying to use python OO within zope.

I created a python script:

class bezeichnung:
	def __init__(self,id,lang='de'):
		self.id				= id
		self.lang			= lang
		self.bezeichnung	= None
		self.status			= None
		self.tstamp			= None
		self._get_details()
	
	def _get_details(self):
		sqlData = context.get_spalte(bez_ref=self.id,lang=self.lang)
		self.bezeichnung	= sqlData['bezeichnung']
		self.status			= sqlData['status']
		self.tstamp			= sqlData['tstamp']

	def store(self):
		sqlReturn = context.put_akt_bezeichnung(bez_ref=self.id,
bezeichnung=self.bezeichnung, lang=self.lang, status=self.status)
	
	def __eq__(self):
		retval = 1
		for attr in self.__dict__:
			if hasattr(other, attr):
				if self.__dict__[attr] <> other.__dict__[attr]:
					retval = -1
			else:
				retval = -1

but when I upload the files I get all kinds of errors about the __
things.

Line 9: "__init__" is an invalid variable name because it starts with
"_"
...

I looked at the Zope book, but it does not mention anything directly
about this, it just say to obay the Zope programming rules.  Now I can
not imagine it not allowing to use OO-Code, so I must be doing something
wrong.

Please help

Thanx
Patrick
-- 

***************************************
COMsulting Gerhard Faehling GmbH
Patrick W. Fraley
Oeverdieker Weg 6
23669 Timmendorfer Strand
Tel: 04503 / 88 12 45
Fax: 04503 / 88 10 18
E-Mail: pf@comsulting.de
Internet: www.comsulting.de
***************************************