• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Grok in Plone
 

Grok in Plone

on

  • 1,379 views

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

Statistics

Views

Total Views
1,379
Views on SlideShare
1,378
Embed Views
1

Actions

Likes
3
Downloads
0
Comments
0

1 Embed 1

http://127.0.0.1 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Grok in Plone Grok in Plone Presentation Transcript

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