[Zope-dev] A product class that subclasses another product

Itai Tavor itavor@vic.bigpond.net.au
Thu, 20 May 1999 12:09:56 +0900


Hi,

I'm building several products that need to share several common attributes
and methods, so I put those is a product ('Master') that the other products
subclass.

My problem is that I can't figure out how to call methods in the Master
class and how to access its attributes.

Very simplified, it looks something like this:

class Master:

    def __init__(self, status, REQUEST=None):
        """Initialize a new master object"""
        self.status = status

    def manage_edit(self, status, REQUEST=None):
        """Change object properties"""
        self.status = status

    def Visible(self):
        """Check if object's status is 'visible'"""
        if self.status == 4:
            return 1
        return 0


from Products.Master import Master
class Foo(Master):

    meta_type = 'Foo'
    id = ''
    icon = 'misc_/Foo/icon'

    def __init__(self, id, title, status, REQUEST):
        """Create a new article entry"""
        self.id            = id
        self.title         = title
        Master(status, REQUEST)

    def manage_edit(self, title, status, REQUEST=None):
        """Change information for object"""
        self.title  = title
        Master.manage_edit(status, REQUEST)


The above simply fails to find the Master methods. I tried
Master.Master.manage_edit, as well as doing self.master = Master(status,
REQUEST) in __init__ and then master.manage_edit(...), but neither worked.
Also, is it possible to access attributes of the Master class, or do I need
to define methods in Master to return attributes?

Thanks
Itai Tavor
--
Itai Tavor                      -- "Je sautille, donc je suis."    --
itavor@vic.bigpond.net.au       --               - Kermit the Frog --
--                                                                 --
-- "Every day, once a day, give yourself a present"  - Dale Cooper --