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

Itai Tavor itavor@vic.bigpond.net.au
Thu, 20 May 1999 18:54:00 +0900


Ok, I think I figured it out, using
http://www.digicool.com/releases/ExtensionClass/ExtensionClass.html and an
old post on this list. Foo.inheritedAttribute('__init__')(self, status,
REQUEST) works.

I now have another problem with these classes. I want to manage the Master
class properties using a management screen that is defined in Master. So,
in Master I define:

    manage_publish = HTMLFile('publish', globals())

And in Foo I add:

    manage_options = (
        ...
        {'label':'Publishing',  'action' :'manage_publish'},

Which works fine. But, in publish.dtml I have:

<FORM ACTION="manage_editPublish" METHOD="post">

manage_editPublish is defined in Master. This doesn't work. When I submit
the form I get a browser dialog asking if I want to download the file
"manage_editPublish" of type "application/x-httpd-cgi". What is going on
here?

>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 --