Lessons Learned: Updating ContentLicensing to be Plone3 compatible <ul><ul><li>David Ray, Brent Lambert Center for Open an...
Disclaimer! <ul><li>We are not Core Developers </li></ul><ul><li>Some solutions presented may not be the definitive way of...
Disclaimer <ul><li>However, issues that we have faced will be relevant to any Zope 3 related work </li></ul><ul><li>We are...
Background <ul><li>Based on PLIP #136 </li></ul><ul><ul><li>http://plone.org/products/plone/roadmap/136 </li></ul></ul><ul...
What it does <ul><li>Licenses content on a per object basis </li></ul><ul><li>Acquires default site license unless specifi...
What it does <ul><li>Able to add additional reusable license(s) to the licensing engine via control panel </li></ul><ul><l...
Who's using it? <ul><li>eduCommons </li></ul><ul><li>Plone4Artists </li></ul><ul><li>EngageMedia </li></ul>
Source Code <ul><li>Plone 3 branch found in Plone Collective </li></ul><ul><ul><li>http://dev.plone.org/collective/browser...
From Zope 2 to Zope 3 <ul><li>Annotations </li></ul><ul><li>Tools vs Local Utilities </li></ul><ul><li>Replacing Placeless...
Annotations <ul><li>DublinCoreExtensions Module </li></ul><ul><ul><li>Adds extended DC metadata to content objects </li></...
Annotations <ul><li>ILicensable interface marks content as annotate-able  </li></ul><ul><li>Marker interface </li></ul>
ILicensable  Interface  <ul><li><class class=&quot;Products.ATContentTypes.content.document.ATDocument&quot;> </li></ul><u...
Annotations <ul><li>Where would annotations be accessed from? </li></ul><ul><ul><li>Placeless script </li></ul></ul><ul><u...
Annotations <ul><li>Zope2 placeless environments  </li></ul><ul><ul><li>Do not have access by default </li></ul></ul><ul><...
Annotations – Placeless Script <ul><li>message = obj.restrictedTraverse('@@change_copyright_view').changeCopyright(copyrig...
Annotations – Zope 2 Page template <ul><li><div tal:replace=&quot;structure context/@@copyright_byline_view|nothing&quot; ...
Annotations – Zope 3 View <ul><li><div tal:omit-tag=&quot;&quot; </li></ul><ul><li>tal:define=&quot;objstuff python:view.g...
Annotations – Archeypes <ul><li>A little more complicated </li></ul><ul><li>customize edit macros </li></ul>
Customizing Archetypes Forms <ul><li>Add field via edit_macros </li></ul><ul><ul><li>check view for availability  </li></u...
Annotations - Indexing <ul><li>ProxyIndex </li></ul><ul><ul><li>AddOn Product </li></ul></ul><ul><ul><li>Don't have to ins...
Annotations - Indexing <ul><li>ProxyIndex allows TALES expressions to retrieve the  value to index an object </li></ul><ul...
Utility <ul><li>Move settable properties to GenericSetup </li></ul><ul><li>Register Utility in setupHandlers.py </li></ul>...
Utility <ul><li>def setupUtilities(site): </li></ul><ul><li>&quot;&quot;&quot; Register a local utility &quot;&quot;&quot;...
Events <ul><li>CMFFormController scripts evolve  </li></ul><ul><li>Determine if placeless script can be assigned to an eve...
Events <ul><li>Recursive License on Folderish Objects </li></ul><ul><ul><li>Fire event on IObjectModified </li></ul></ul><...
Events <ul><li>Check state of Object for certain events </li></ul><ul><ul><li>IObjectAddedEvent </li></ul></ul>
Viewlets <ul><li>Do you need to customize all those page templates? </li></ul><ul><li>Viewlets can simplify codebase </li>...
Viewlets <ul><li>Beware! Layer management incomplete! </li></ul><ul><li>ZCML executed regardless of whether or not layer i...
Formlib - ControlPanel <ul><li>Separate concerns with interfaces/fieldsets </li></ul><ul><ul><li>Content License Settings ...
Formlib : ControlPanel <ul><li>New License Form </li></ul><ul><ul><li>getter/setter of properties does nothing </li></ul><...
Formlib  <ul><li>Custom Widgets </li></ul><ul><ul><li>Hidden fields </li></ul></ul><ul><ul><ul><li>Attach to existing cust...
Other Examples <ul><li>eduCommons Course Builder Widget </li></ul><ul><ul><li>Existing vs New Division </li></ul></ul>
Questions?
Additional Resources <ul><li>http://cosl.usu.edu/projects/plone-add-on-products/ </li></ul><ul><ul><li>List of COSL author...
Upcoming SlideShare
Loading in...5
×

David Rey Lessons Learned Updating Content Licensing To Be Plone 3 Compatible

3,208

Published on

This session will provide an overview of updating a Plone 2 Add On product to Plone 3. I will discuss the methods and tools used to refactor the codebase. This includes pointers on how to use GenericSetup and extension profiles to install your product, moving Zope2 tools to Zope3 utilities, and creation of control panel configlets using formlib. One of the biggest problems we faced in moving our codebase to Plone3 was the lack of readily available sample code to work from. We would like to make an example of the transition of ContentLicensing from Plone2 to Plone3 and provide this resource to the Plone community.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,208
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
48
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

David Rey Lessons Learned Updating Content Licensing To Be Plone 3 Compatible

  1. 1. Lessons Learned: Updating ContentLicensing to be Plone3 compatible <ul><ul><li>David Ray, Brent Lambert Center for Open and Sustainable Learning Utah State University </li></ul></ul>
  2. 2. Disclaimer! <ul><li>We are not Core Developers </li></ul><ul><li>Some solutions presented may not be the definitive way of solving Zope 3 issues </li></ul>
  3. 3. Disclaimer <ul><li>However, issues that we have faced will be relevant to any Zope 3 related work </li></ul><ul><li>We are still learning, and welcome suggestions and feedback </li></ul>
  4. 4. Background <ul><li>Based on PLIP #136 </li></ul><ul><ul><li>http://plone.org/products/plone/roadmap/136 </li></ul></ul><ul><ul><li>'neutral licensing engine' </li></ul></ul><ul><ul><li>standard behavior for all types </li></ul></ul><ul><li>Result of remote sprinting at Big Apple Sprint in Summer 2006 </li></ul>
  5. 5. What it does <ul><li>Licenses content on a per object basis </li></ul><ul><li>Acquires default site license unless specifically set </li></ul><ul><li>Provides support for Creative Commons, GNU, All Rights Reserved </li></ul>
  6. 6. What it does <ul><li>Able to add additional reusable license(s) to the licensing engine via control panel </li></ul><ul><li>Able to add custom license per object, as needed </li></ul><ul><li>Demo </li></ul>
  7. 7. Who's using it? <ul><li>eduCommons </li></ul><ul><li>Plone4Artists </li></ul><ul><li>EngageMedia </li></ul>
  8. 8. Source Code <ul><li>Plone 3 branch found in Plone Collective </li></ul><ul><ul><li>http://dev.plone.org/collective/browser/ContentLicensing/branches/cosl-plone3 </li></ul></ul><ul><ul><li>Place in Products directory, apply profile to new Plone Site </li></ul></ul><ul><li>eduCommons project </li></ul><ul><ul><li>http://cosl.usu.edu/trac/browser/eduCommons3/trunk </li></ul></ul>
  9. 9. From Zope 2 to Zope 3 <ul><li>Annotations </li></ul><ul><li>Tools vs Local Utilities </li></ul><ul><li>Replacing Placeless Scripts </li></ul><ul><li>Custom Views </li></ul><ul><li>Using the new Control Panel </li></ul>
  10. 10. Annotations <ul><li>DublinCoreExtensions Module </li></ul><ul><ul><li>Adds extended DC metadata to content objects </li></ul></ul><ul><ul><ul><li>Rights License </li></ul></ul></ul><ul><ul><ul><li>Rights Holder </li></ul></ul></ul><ul><ul><li>Mitigates ambiguity of default Copyright field </li></ul></ul>
  11. 11. Annotations <ul><li>ILicensable interface marks content as annotate-able </li></ul><ul><li>Marker interface </li></ul>
  12. 12. ILicensable Interface <ul><li><class class=&quot;Products.ATContentTypes.content.document.ATDocument&quot;> </li></ul><ul><li><implements interface=&quot;Products.ContentLicensing.DublinCoreExtensions.interfaces.ILicensable zope.annotation.interfaces.IAttributeAnnotatable” </li></ul><ul><li>/> </li></ul><ul><li></class> </li></ul>
  13. 13. Annotations <ul><li>Where would annotations be accessed from? </li></ul><ul><ul><li>Placeless script </li></ul></ul><ul><ul><li>Zope3 View </li></ul></ul><ul><ul><li>Archetypes generated form </li></ul></ul><ul><li>How to access annotations in these situations? </li></ul>
  14. 14. Annotations <ul><li>Zope2 placeless environments </li></ul><ul><ul><li>Do not have access by default </li></ul></ul><ul><ul><li>Can provide access through zope 3 views </li></ul></ul><ul><ul><li>Access from placeless scripts via restrictedTraverse() </li></ul></ul><ul><ul><li>Access from page templates using the structure tag </li></ul></ul>
  15. 15. Annotations – Placeless Script <ul><li>message = obj.restrictedTraverse('@@change_copyright_view').changeCopyright(copyright_action) </li></ul>
  16. 16. Annotations – Zope 2 Page template <ul><li><div tal:replace=&quot;structure context/@@copyright_byline_view|nothing&quot; /> </li></ul>
  17. 17. Annotations – Zope 3 View <ul><li><div tal:omit-tag=&quot;&quot; </li></ul><ul><li>tal:define=&quot;objstuff python:view.getLicenseAndHolderFromObject(here); </li></ul><ul><li>objHolder python:objstuff[0]; </li></ul><ul><li>objLicense python:objstuff[1]; </li></ul><ul><li>objLicenseId python:objLicense[0];&quot;> </li></ul>
  18. 18. Annotations – Archeypes <ul><li>A little more complicated </li></ul><ul><li>customize edit macros </li></ul>
  19. 19. Customizing Archetypes Forms <ul><li>Add field via edit_macros </li></ul><ul><ul><li>check view for availability </li></ul></ul><ul><ul><li><tal:licensingfield tal:condition=&quot;python:fieldset == 'ownership'&quot;> </li></ul></ul><ul><ul><li><div tal:replace=&quot;structure context/@@dc_metadata| nothing &quot; /> </li></ul></ul><ul><ul><li></tal:licensingfield> </li></ul></ul>
  20. 20. Annotations - Indexing <ul><li>ProxyIndex </li></ul><ul><ul><li>AddOn Product </li></ul></ul><ul><ul><li>Don't have to install </li></ul></ul><ul><ul><li>Lives in Products directory </li></ul></ul><ul><li>http://infrae.com/download/ProxyIndex </li></ul>
  21. 21. Annotations - Indexing <ul><li>ProxyIndex allows TALES expressions to retrieve the value to index an object </li></ul><ul><li>Defined in setupHandlers.py </li></ul>
  22. 22. Utility <ul><li>Move settable properties to GenericSetup </li></ul><ul><li>Register Utility in setupHandlers.py </li></ul><ul><li>Explicity setSite(site) to register </li></ul>
  23. 23. Utility <ul><li>def setupUtilities(site): </li></ul><ul><li>&quot;&quot;&quot; Register a local utility &quot;&quot;&quot; </li></ul><ul><li>if not Isite.providedBy(site): </li></ul><ul><li>enableLocalSiteHook(site) </li></ul><ul><li>setSite(site) </li></ul><ul><li>sm = getSiteManager() </li></ul><ul><li>if not sm.queryUtility(IContentLicensingUtility): </li></ul><ul><li>sm.registerUtility(ContentLicensingUtility('contentlicensing'), </li></ul><ul><li>IContentLicensingUtility) </li></ul>
  24. 24. Events <ul><li>CMFFormController scripts evolve </li></ul><ul><li>Determine if placeless script can be assigned to an event </li></ul>
  25. 25. Events <ul><li>Recursive License on Folderish Objects </li></ul><ul><ul><li>Fire event on IObjectModified </li></ul></ul><ul><ul><li><subscriber for=&quot;Products.ATContentTypes.content.folder.ATFolder zope.app.event.interfaces.IObjectModifiedEvent” handler=&quot;.events.recursive_license” /> </li></ul></ul>
  26. 26. Events <ul><li>Check state of Object for certain events </li></ul><ul><ul><li>IObjectAddedEvent </li></ul></ul>
  27. 27. Viewlets <ul><li>Do you need to customize all those page templates? </li></ul><ul><li>Viewlets can simplify codebase </li></ul>
  28. 28. Viewlets <ul><li>Beware! Layer management incomplete! </li></ul><ul><li>ZCML executed regardless of whether or not layer is installed </li></ul>
  29. 29. Formlib - ControlPanel <ul><li>Separate concerns with interfaces/fieldsets </li></ul><ul><ul><li>Content License Settings </li></ul></ul><ul><ul><li>Add New License </li></ul></ul><ul><li>Control Panel Adapter </li></ul><ul><ul><li>Adapts schema of Control Panel to Plone Site </li></ul></ul>
  30. 30. Formlib : ControlPanel <ul><li>New License Form </li></ul><ul><ul><li>getter/setter of properties does nothing </li></ul></ul><ul><ul><li>handle data in handle_edit_action </li></ul></ul><ul><ul><ul><li>also handles default view </li></ul></ul></ul>
  31. 31. Formlib <ul><li>Custom Widgets </li></ul><ul><ul><li>Hidden fields </li></ul></ul><ul><ul><ul><li>Attach to existing custom widget </li></ul></ul></ul><ul><ul><ul><li>Formlib doesn't provide a hidden widget </li></ul></ul></ul><ul><ul><li>ccwidget.pt </li></ul></ul>
  32. 32. Other Examples <ul><li>eduCommons Course Builder Widget </li></ul><ul><ul><li>Existing vs New Division </li></ul></ul>
  33. 33. Questions?
  34. 34. Additional Resources <ul><li>http://cosl.usu.edu/projects/plone-add-on-products/ </li></ul><ul><ul><li>List of COSL authored projects </li></ul></ul><ul><ul><li>Check Plone3 branches for additional examples </li></ul></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×