The document discusses subtyping in Plone and presents an example of creating a new document subtype called "UltraDoc" using the p4a.subtyper package. The example shows how to define a marker interface, descriptor class, template, and ZCML configuration to integrate the new subtype into Plone so it appears as its own content type with a customized view. The presentation aims to demonstrate how subtyping can be used to provide different identities for content and transform content based on events.
4. Why Subtype?
Many possible faces for an
existing content type
Simple conversion
Delayed specification
Subtyping Unleased! Slide 4 Plone Conference 2007 – Naples
5. Use Cases
Need different content identity
depending on situation
Need some way to transform
identity based on event reaction
Subtyping Unleased! Slide 5 Plone Conference 2007 – Naples
6. p4a.subtyper
Minimal framework
Hooks up subtypes into content
menu
Subtyping Unleased! Slide 6 Plone Conference 2007 – Naples
7. An Example:
Setting up p4a.subtyper
easy_install p4a.subtyper
Subtyping Unleased! Slide 7 Plone Conference 2007 – Naples
8. An Example:
Creating New Package
p4a.subtyperdemo
Example source at:
http://www.plone4artists.org
/svn/projects/p4a.subtyperdemo/
Subtyping Unleased! Slide 8 Plone Conference 2007 – Naples
9. An Example:
Sub-type Marker Interface
New module named interfaces
New interface named IUltraDoc
Subtyping Unleased! Slide 9 Plone Conference 2007 – Naples
10. An Example:
Sub-type Marker Interface
class IUltraDoc(interface.Interface):
quot;quot;quot;A new ultra document subtype.quot;quot;quot;
interface.alsoProvides(IUltraDoc,
IContentType)
Subtyping Unleased! Slide 10 Plone Conference 2007 – Naples
11. An Example:
Sub-type Descriptor
New module named
descriptors
New descriptor named
UltraDocDescriptor
Subtyping Unleased! Slide 11 Plone Conference 2007 – Naples
13. An Example:
New View
New template called ultradoc.pt
Subtyping Unleased! Slide 13 Plone Conference 2007 – Naples
14. An Example:
New View
<div metal:fill-slot=quot;mainquot;>
<h2>This is an ultradoc!</h2>
<h3 tal:content=quot;context/Titlequot;></h3>
<p
tal:content=quot;context/Descriptionquot;></p>
</div>
Subtyping Unleased! Slide 14 Plone Conference 2007 – Naples
15. An Example:
Tying Together – ZCML
Register descriptor as utility
Hook new view up applying to
marker interface
Subtyping Unleased! Slide 15 Plone Conference 2007 – Naples