[Zope-dev] Python Product as DataSkin

Steve Alexander steve@cat-box.net
Mon, 19 Feb 2001 18:45:55 +0000


Michael R. Bernstein wrote:

> Steve Alexander wrote:
> 
>> Is the __init__ method of DataSkin getting called?
>> 
>> This would happen if, for example, you define an __init__ method in your
>> class, but you don't use something like:
>> 
>> from Globals import default__class_init__
>> 
>> default__class_init__(yourClass)
>> 
>> At least, I *think* that's one of the things that default__class_init__
>> does.

Nope... I got confused. Globals.default__class_init__ sets up the security
attributes for you class, from whatever combination of security
declarations you've used.

In Zope 2.3) it is aliased to Globals.InitializeClass.

Use it by having

  import Globals

somewhere in your class definition, and 

  Globals.InitializeClass(YourClassName)

at the end.

See the following URL for more information:

http://www.zope.org//Wikis/DevSite/Projects/DeclarativeSecurity/ZopeSecurityForDevelopers


>> Otherwise, you'll need to make sure you call DataSkin.__init__
>> from your __init__ method, probably using Acquisition.inheritedAttribute.)

So, at the start of your __init__ method, call:
   NameOfYourClass.inheritedAttribute('__init__')(self, id)

Your __init__ method might look like this:

   def __init__(self, id, title):
       FooClass.inheritedAttribute('__init__')(self, id)
       # rest of your __init__ method


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net