rocky burt subtyping unleashed
DESCRIPTION
Subtyping is a new pattern for extending the functionality of existing content types as provided by Plone. Zope 3 enables subtyping using adapters and views. After this session, attendees will be capable of adding additional functionality to content types using subtyping and Zope 3. The Plone4Artists suite of projects will be used to demonstrate existing uses of subtyping. Attendees will be expected to understand the basics of the Zope 3 CA particularly concerning interfaces, adapters, and views. They will also need to understand the basics of ATContentTypes and how they relate to Plone.TRANSCRIPT
Subtyping Unleased!Speaker: Rocky Burt
Slide 2Subtyping Unleased! Plone Conference 2007 – Naples
Who I Am
Rocky BurtServerZen Software
http://www.serverzen.com
Slide 3Subtyping Unleased! Plone Conference 2007 – Naples
Subtyping?
Narrow classification Functionality hook
Slide 4Subtyping Unleased! Plone Conference 2007 – Naples
Why Subtype?
Many possible faces for an existing content type
Simple conversion Delayed specification
Slide 5Subtyping Unleased! Plone Conference 2007 – Naples
Use Cases
Need different content identity depending on situation
Need some way to transform identity based on event reaction
Slide 6Subtyping Unleased! Plone Conference 2007 – Naples
p4a.subtyper
Minimal framework Hooks up subtypes into content
menu
Slide 7Subtyping Unleased! Plone Conference 2007 – Naples
An Example:Setting up p4a.subtyper
easy_install p4a.subtyper
Slide 8Subtyping Unleased! Plone Conference 2007 – Naples
An Example:Creating New Package
p4a.subtyperdemo
Example source at:
http://www.plone4artists.org
/svn/projects/p4a.subtyperdemo/
Slide 9Subtyping Unleased! Plone Conference 2007 – Naples
An Example:Sub-type Marker Interface
New module named interfaces New interface named IUltraDoc
Slide 10Subtyping Unleased! Plone Conference 2007 – Naples
An Example:Sub-type Marker Interface
class IUltraDoc(interface.Interface): """A new ultra document subtype."""
interface.alsoProvides(IUltraDoc, IContentType)
Slide 11Subtyping Unleased! Plone Conference 2007 – Naples
An Example:Sub-type Descriptor
New module named descriptors
New descriptor named UltraDocDescriptor
Slide 12Subtyping Unleased! Plone Conference 2007 – Naples
An Example:Sub-type Descriptor
class UltraDocDescriptor(object): implements(IPortalTypedDescriptor) title = u'Ultra Doc' description = u'New ultra style '\ u'document.' type_interface = IUltraDoc for_portal_type = 'Document
Slide 13Subtyping Unleased! Plone Conference 2007 – Naples
An Example:New View
New template called ultradoc.pt
Slide 14Subtyping Unleased! Plone Conference 2007 – Naples
An Example:New View
<div metal:fill-slot="main"><h2>This is an ultradoc!</h2><h3 tal:content="context/Title"></h3><p tal:content="context/Description"></p></div>
Slide 15Subtyping Unleased! Plone Conference 2007 – Naples
An Example:Tying Together – ZCML
Register descriptor as utility Hook new view up applying to
marker interface
Slide 16Subtyping Unleased! Plone Conference 2007 – Naples
An Example:Tying Together – ZCML
<utility name="ultradoc" factory=".descriptors.UltraDocDescriptor" />
<browser:page for=".interfaces.IUltraDoc" name="document_view" permission="zope2.View" template="ultradoc.pt" />
Slide 17Subtyping Unleased! Plone Conference 2007 – Naples
An Example:Before
Slide 18Subtyping Unleased! Plone Conference 2007 – Naples
An Example:After
Slide 19Subtyping Unleased! Plone Conference 2007 – Naples
An Example:Regular Content
Slide 20Subtyping Unleased! Plone Conference 2007 – Naples
Other Features
Special subtype events Extension by adapters and
schema's
Slide 21Subtyping Unleased! Plone Conference 2007 – Naples
Conclusion
Questions?Comments?Resources at:
http://www.serverzen.com/training/subtyping-unleashed