Re: Our story for re-using content types

George Lee <[email protected]>
Newsgroups gmane.comp.web.zope.plone.archetypes.devel
Message-ID <[email protected]>
> >   from Bluh import ClassA
> >  def MyClassA(ClassA):
> >       pass
> > 
> > What happens to:
> >   * all the installation code you use for ClassA
> >   * how meta_type, portal_type, archetype_name of the classes work,
> > how they show up in add menus (both? by waht name?)
> >   * any other interactions between ClassA and other portal objects
> > (e.g., if it looks up info in a property sheet, or a vocabulary
> > manager, etc.)
> 
> My advice is - don't do this unless you have a really good reason  
> to.


Don't the same questions apply to when you re-use a content type, though? In
which case it isn't a mere Python wrapper / module alias that's going on. It
seems like to create a good Archetype that you can reuse, subclass, etc. you
have to worry about the above things and code it very well to start with so that
subclassing, etc. later on is simple.

For instance, it seems like this would involve making generic installation code
with a method that could be called by a newly defined content type that
subclasses the original content-type. (I half-shudder thinking about subclassing
RichDocument, for instance, given the installation code it requires. Although
actually that is fairly clean so that's not a full shudder.)

And as for coding the relationship between a class and other portal objects, I
suppose that these should all happen inside methods that can be overriden, for
instance

  def _lookupDataFromPropertySheet(self):
      return getToolByName(self, 'portal_properties').new_props.getProperty('data')

  def processData(self):
      return 'Data: %s' % self._lookupDataFromPropertySheet()

rather than

  def processData(self):
      return 'Data: %s' % getToolByName(self,
'portal_properties').new_props.getProperty('data')

I don't know though, I feel like I'm making stuff up here.

Peace,
George



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.