[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Extending Zope

nobody@nowhere.com nobody@nowhere.com
Mon, 02 Sep 2002 10:34:55 -0400

A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/CustomZopeObjects.stx#2-59


    Writing Python base classes is easy, but it involves a few installation
    details. To create a Python base class you need access to the
    filesystem. Create a directory inside your *lib/python/Products*
    directory named *AnimalBase*. In this directory create a file named
    *Animal.py* with these contents::

      class Animal: 
          A base class for Animals


          def eat(self, food, servings=1):
              Eat food

          def sleep(self):

          def hungry(self):
              Is the Animal hungry?
              return self._hungry

      % Anonymous User - Sep. 2, 2002 10:34 am:
       Let's suppose I need an __init__ method for class Animal: I found that this __init__ method, if present, is
       automatically called when I create an instance of
       the ZClass that "wraps" (inherits from) Annimal. But what if __init__ has parameters? Where can I pass these
       parameters from? I guess the right place is from the Animal_add dtml method that acts as a constructor, but
       what's the dtml for doing so? Please help!