1

如何archetypes.schemaextenders注册five.grok.

尝试:

class QuickNavExtender(grok.Adapter):
    """
    Define schema fiddler which injects a new field to every item.
    """

    # This field comes on every AT content item
    grok.adapts(ISchemaExtender)
    grok.provider(ISchemaExtender)
    grok.context(IBaseContent)

    #adapts(IBaseContent)
    implements(ISchemaExtender)    

    fields = [
            ExtensionBooleanField("quicknav",
                widget = atapi.BooleanWidget(
                    label="Quick jump navigation",
                    description="Allow in-page jumping by navigation links"
                ),

                # On which edit tab this field appears
                schemata = "settings"
            )
    ]

...没有被捡起。

但是,如果您添加此 ZCML 片段并回退 Zope 3 样式注册,则它可以工作:

<adapter factory=".extender.QuickNavExtender"
   provides="archetypes.schemaextender.interfaces.ISchemaExtender" />
4

1 回答 1

3

我想你想要:

class QuickNavExtender(grok.Adapter):
    grok.context(IBaseContent)
    grok.implements(ISchemaExtender)
    # fields here...
于 2012-05-10T20:43:43.957 回答