Hi Morten,


   There are two ways to subclass products. You can use straightforward
Python subclassing:

e.g.,In your custom Product.. here is an example from Zwiff:

> import Products.PythonMethod.Guarded
> 
> from Globals import HTMLFile, MessageDialog
> from App import Common
> 
> manage_addZwiffForm = HTMLFile('addForm',globals())
> 
> def manage_addZwiff(self, id, title, params, body, REQUEST=None):
>     """Add A Zwiff to a folder .... just like PythonMethod.. 
>     """
>     it = Zwiff(id, title, params, body)
>     self._setObject(id, it)
>     return self.manage_main(self, REQUEST)
> 
> def handleMovieOutput(movie, RESPONSE):
> 
>     fname = tempfile.mktemp()
> 
>     movie.save(fname)
> 
>     f = open(fname)
>     s = f.read()
>     f.close()
> 
>     RESPONSE.setHeader('Content-type', 'application/x-shockwave-flash')
>     
>     os.remove(fname)
>     
>     return s
> 
> class Zwiff (Products.PythonMethod.PythonMethod.PythonMethod ):
> 
>     meta_type = 'Zwiff'
> 
>     def makeFunction(self, compile=0):
>         from Products.PythonMethod.Guarded import GuardedBlock, safefuncs, theGuard
>         if compile:
>             self._checkCBlock(GuardedBlock)
>         if self.errors:
>             raise "Python Method Error", string.join(self.errors, '\n')
>         return self._newfun(compile, {'$guard': theGuard},
>               __builtins__=mysafebin, _=safefuncs)
> 
> 

So the class Zwiff is a subclass of PythonMethod. Look at Zwiff for the full
source: http://www.zope.org/Members/sspickle/Zwiff

Or you can create a ZClass that subclasses from a 'base class'. To do
this you've got to register the base class with the ZClass machinery
(e.g., here is the code for ZCVSMixin that does this....  ZCVSMixin
is a base class... CVSFolder is a full blown product that happens
to be a subclass of ZCVSMixin... )

> 
> 
> import ZCVSMixin
> import CVSFolder
> 
> __doc__ = ZCVSMixin.__doc__
> __version__ = ZCVSMixin.__version__
> 
> def initialize(context):
>     context.registerClass(
>         CVSFolder.CVSFolder,
>         constructors=(CVSFolder.manage_addCVSFolderForm,
>                       CVSFolder.manage_addCVSFolder),
>         icon='fish.gif',
>         )
>     context.registerBaseClass(ZCVSMixin.ZCVSMixin)
> 

does that help?

take care,
-steve

_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to