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

Michel Pelletier michel@digicool.com
Sun, 23 May 1999 13:23:15 -0400


> -----Original Message-----
> From: Itai Tavor [mailto:itavor@vic.bigpond.net.au]
> Sent: Wednesday, May 19, 1999 11:10 PM
> To: zope-dev@zope.org
> Subject: [Zope-dev] A product class that subclasses another product
> 
> 
> 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?
> 

Your question could best be answered on the Python mailing list, as this
is a Python question (in the context of Zope).  I suspect Computed
attributes could help you out here in ExtensionClasses, but there may be
a Python mechanism I am unaware of that can solve the problem without
using Computed attributes.

The Python list can be found at http://www.python.org

-Michel


> 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 --
> 
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://www.zope.org/mailman/listinfo/zope-dev
> 
> (For non-developer, user-level issues, use the companion list,
> zope@zope.org, http://www.zope.org/mailman/listinfo/zope )
>