Grok in Plone

  • 1,125 views
Uploaded on

These are the slides for the talk I gave at the PloneSA group meeting in Cape Town on Wednesday 6 July 2011

These are the slides for the talk I gave at the PloneSA group meeting in Cape Town on Wednesday 6 July 2011

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,125
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
4

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Using Grok in Plone with Five.Grok
    • JC Brand
    • 2. [email_address]
    • 3. http://opkode.com
  • 4. What is Grok?
    • Web application framework built on Zope 3
      • Inspired by Ruby on Rails
        • Convention over configuration
        • 5. Don't repeat yourself
      • Aims avoid the need for ZCML
    • http://grok.zope.org
  • 6. What is Grok?
    • Both Grok/Plone uses Zope Toolkit (ZTK)
    • 7. ZTK uses Zope Component Architecture (ZCA)
    • 8. ZCA also used by Pyramid/Pylons
    • 9. Distinguishing Grok features (also in Plone):
      • Component Architecture (ZCA)
      • 10. Object Database (ZODB)
      • 11. Object publishing and traversal
  • 12. Zope Component Architecture
    • Allows developers to create reusable components
    • 13. Components are objects with Interfaces
    • 14. Many-to-one mapping between objs and Interfaces, can be interchanged.
    • 15. ZCA has roughly 2 kinds of components:
      • Adapters extend other components or models/content types.
      • 16. Utilities, standalone (config, db connect, mail etc.)
    • ZCA allows extending 3rd party code without direct/edit access to it
  • 17. Grok does away with ZCML
    • In ”plain” Zope, developer writes component in Python and registers it for ZCA in ZCML.
    • 18. ZCML = glue or wiring
    • 19. Grok lets you use python statements instead of ZCML
    • 20. Keeps glue and code together
    • 21. Makes it easier to see what registrations are in effect
    • 22. Reduces need to context switch files/syntaxes
  • 23. Using Five.Grok in Plone
    • BrowserViews
      • Common display technology in Zope
      • 24. In use in Plone, BlueBream, Grok, Pyramid
      • 25. BrowserView is a multi-adapter (i.e ZCA component)
      • 26. Python class containing ”display logic”, registered as a multi-adapter for Request and content-type.
      • 27. Normally has template, but not required (i.e Ajax)
      • 28. Doesn't always return anything (i.e redirects)
      • 29. See: plonesa.grok/browser/*
  • 30. Using Five.Grok in Plone
    • Adapters
      • Most powerful concept of ZCA
      • 31. Adapts an object of specific Interface, to also provide functionality specified by the adapter's interface.
      • 32. Analogous to Type Casting
      • 33. Real world analogy: Wall plug adapters
      • 34. plonesa/grok/adapter.py
  • 35. Using Five.Grok in Plone
    • Viewlets
      • Snippets of reusable HTML for rendering as part of a page (not the whole page).
      • 36. Similarities with BrowserViews
      • 37. Render inside ViewletManagers
      • 38. plonesa/grok/browser/viewlet.py
  • 39. Event subscribers
    • Event subscribers
      • Also called event listeners
      • 40. Zope provides an events system
      • 41. Components notify the subscribers of a particular event.
      • 42. Code execution is blocked until all subscribers are done.
      • 43. plonesa/grok/events.py
  • 44. Other Five.Grok functionality
    • Annotations
      • Grok's Annotations are Adapters with attributes that persist (i.e can be stored).
      • 45. Plone uses IAnnotations from zope.annotation which has a dict-like API.
      • 46. Grok's pattern can cause problems when code is moved or uninstalled (which happens often in Plone)
      • 47. http://pypi.python.org/pypi/grokcore.annotation
  • 48. Other Five.Grok functionality
    • Defining Permissions
      • Grok uses grok.Permission
      • 49. In Plone we define permissions in GS-XML configuration files rather than code.
      • 50. See: http://pypi.python.org/pypi/grokcore.security
    • Utilities
      • Global (Zope-wide) or local utilities (Plone or folder-wide)
      • 51. For local, Grok uses grokcore.site
      • 52. In Plone we use componentregistry.xml GS-XML
  • 53. Other Five.Grok functionality
    • Resource directories
      • Grok has an implicit static directory
      • 54. Can also use grok.DirectoryResource instead of <browser.resourceDirectory/> directive.
      • 55. See http://pypi.python.org/pypi/grokcore.view
  • 56. Other Five.Grok functionality
    • Browser Layers
      • Can use grok.skin()
      • 57. In Plone we use browserlayer.xml in GenericSetup
      • 58. Alternatively SkinLayers via plone.theme package and configure.zcml
  • 59. Other Five.Grok functionality
    • Forms
      • Grok uses grokcore.formlib
        • Megrok.z3cform
      • Plone still uses/supports formlib but momentum is moving towards z3c.form (i.e Dexterity )
        • collective.z3cform.grok
  • 60. Other Five.Grok functionality
    • Content Types
      • Grok uses grok.Model
      • 61. Plone uses Dexterity and Archetypes
    • Ordering Viewlets
      • Grok uses g rok.order() to order viewlets based on integer weighting.
      • 62. Plone uses plone.app.viewletmanager and GS-XML instead.
  • 63. Other Five.Grok functionality
    • Static resources dir
      • Grok has a special dir static for static resources (JS and CSS)
      • 64. Can be accessed via TAL: view/static/stylesheet.css
      • 65. In Plone this will always be relative to the context, rather than relative to site navigation root, which means it doesn't cache well.
      • 66. Construct URL manually instead.
      • 67. See: http://pypi.python.org/pypi/grokcore.view
  • 68. Thanks and Credits
    • Carlos de la Guardia
      • Grok 1.0 Web Development
      • 69. http://bit.ly/lf7sci
    • Martin Aspeli
      • http://bit.ly/iyESUB