Step 2: Extend the Folder Type (Everywhere!)
Next, we identify the content type we want to extend. In this case, it will be the Folder content type.
To do this, we add the following line to Products.StartingPoint/Products/StartingPoint/configure.zcml:
...
<cmf:registerDirectory name="starting_point" />
<adapter factory=".extender.FolderImageExtender" />
</configure>
And we create the new file Products.StartingPoint/Products/StartingPoint/extender.py:
from Products.Archetypes.public import ImageField, ImageWidget, StringField, StringWidget
from Products.ATContentTypes.interface import IATFolder
from archetypes.schemaextender.field import ExtensionField
from archetypes.schemaextender.interfaces import ISchemaExtender
from zope.component import adapts
from zope.interface import implements
class _ExtensionImageField(ExtensionField, ImageField): pass
class _ExtensionStringField(ExtensionField, StringField): pass
class FolderImageExtender(object):
adapts(IATFolder)
implements(ISchemaExtender)
fields = [
_ExtensionImageField(
"folderimage",
widget = ImageWidget(
label=u"Folder Image",
description=u"Image to display with the folder",
),
),
_ExtensionStringField(
"folderimagetitle",
widget = StringWidget(
label=u"Image Title",
description=u"Title of image to display with the folder",
),
),
]
def __init__(self, context):
self.context = context
def getFields(self):
return self.fields
At this point, if we run Buildout and reinstall our product, all of our sites will have this new extender—whether we want them to or not! So, in the next step, we will make the extender apply only on sites where we have installed the product.


