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 ***************************************
Python scripts are limited to a subset of Python because they are considered a potential security problem. You can relax some of the restictions (mostly library limits)--see the comments in the PythonScript product. External Methods and Products, both Python based, do not have the limitations imposed on Python scripts because they require trusted access to the Zope system. External methods are simple to use; the interface into Zope needs to be limited to simple opbjects (lists, dictionaries, etc.). Products (with appropriate inheritance and mixins) don't have the limitatons of external methods and can define first-class objects that can be passed around. On 24 Apr 2003, Patrick W. Fraley wrote:
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: [...] but when I upload the files I get all kinds of errors about the __ things. [...] 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 --
participants (2)
-
Dennis Allison -
Patrick W. Fraley