Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Tips / Grok Framework

Grok Framework

Grok 扮演 Zope 3 的 wrapper 角色,它簡化 component 註冊流程,提供存取 Zope 3 的 API 功能。從 Plone 3.3 開始,可以透過 five.grok 使用 Grok 功能。但從 Plone 5 開始,Grok 或 collective.fastview 不再是預設推薦的機制。

Grok 是否該留在 Plone Core 裡,結論是不要,目的是減少技術相依性。

grok framework on developer documentation grok rules five.grok Core Grok Concepts

add viewlets

meta.py 在 Plone 4.3 運作方式改變

Plone 4.3 環境下 static 目錄不再自動被掃描

ZCML allowed_attributes 對應方式

Dexterity

grok (five.grok, grokcore.view, grokcore.security, grokcore.component, grokcore.viewlet, grokcore.site, grokcore.annotation, martian?, plone.directives.form or plone.directives.dexterity) relations (from z3c.relationfield.schema import RelationList, RelationChoice)

Optional Extras: [grok] [relations]

http://www.martinaspeli.net/articles/dexterity-meet-grok

http://www.martinaspeli.net/articles/grok-and-martian-rocks

install_requires=[
  ...,
  'plone.app.dexterity [grok]',
  ...,

Learning By Examples

FAQ.py collective.pece

Dependency

Plone 4.3 開始昇級並移除相依關係 Plone 5 文件移除 Grok 範例: collective.upload

  • setup.py 移除 five.grok,configure.zcml 移除 <grok:grok>
  • 移除 from five import grok
  • 手動註冊 static media folder
  • 透過 configure.zcml 註冊 View 和 Form
  • 透過 <browser:page> 來移除 grok.templatedir() 並註冊 View Class

移除相依關係範例: <grok.grok package="."> plone.app.standardtiles collective.twitter.portlets plone.directives.form collective.history collective.z3cform.datagridfield collective.fingerpointing collective.polls grok.context grok.name grok.implements grok.Adapter plone.app.stagingbehavior collective.dexteritytextindexer grok_component #1 #2 collective.z3cform.datagridfield

setup.py

my/package/configure.zcml

my/package/interfaces.py

plone.directives.form 相依於 five.grok 和 grokcore.* 模組,已經不鼓勵使用,建議改用 plone.supermodel 和 plone.autoform,移除範例: collective.cover

grok.name() 在 Plone 4.3 預設已不支援

grok.implements() 等同於 implements() 或 @implementer()

from five import grok
class ImportantStuff(object):
    grok.implements(IImportant)

from zope.interface import implementer
@implementer(IImportant)
class ImportantStuff(object):

plone.directive.form Removal: collective.dexteritytextindexer

collective.cover 額外安裝了 grokcore.view grokcore.viewlet grokcore.site grokcore.security grokcore.component grokcore.annotation

Related content
Portlet Management