创建灵巧内容的类grok指令

plone.directives.dexterit的Python项目详细描述


plone.directives.dexterity

这个包提供了可选的、类似grok的指令来配置 灵巧的内容。这取决于5。格罗克,这又取决于 各种可重用的grokcore.*包,但不是grok本身。

另请参见plone.directives.form,它提供了用于配置的指令 模式与表单提示接口。

内容类

扩展灵活的“item”和“container”基类的内容可以是 为了注册工厂和/或zmi add权限而摸索。

例如:

from plone.directives import dexterity
from plone.directives import form
from five import grok
from zope import schema

class IPage(form.Schema):

    title = schema.TextLine(title=u"Title")

    description = schema.Text(title=u"Description",
                          description=u"Summary of the body")

    body = schema.Text(title=u"Body text",
                       required=False,
                       default=u"Body text goes here")

    details = schema.Text(title=u"Details",
                          required=False)

class FSPage(dexterity.Item):
    grok.implements(IPage)
    grok.name('example.page')

    def __init__(self, id=None, title=None, description=None, body=None, details=None):
        self.id = id # required - or call super() with this argument
        self.title = title
        self.description = description
        self.body = body
        self.details = details

如果一个工厂实用程序不在 “example.fspage”的名称。

也可以使用“add_permission()”指令使类型 注册为Zope2内容类,与 <;five:registerClass/>;指令执行:

class ZopeTwoItem(dexterity.Item):
    grok.implements(IPage)
    dexterity.add_permission('cmf.AddPortalContent')
    portal_type = 'example.zopetwopage'

但是,对于大多数内容类型,这是不必要的。

表格

若要为类型创建灵活的“添加”、“编辑”或“显示”窗体,请使用 addform、editform或displayform基类。例如:

from plone.directives import dexterity
from plone.directives import form
from five import grok
from zope import schema

class IPage(form.Schema):

    title = schema.TextLine(title=u"Title")

    description = schema.Text(title=u"Description",
                          description=u"Summary of the body")

    body = schema.Text(title=u"Body text",
                       required=False,
                       default=u"Body text goes here")

    details = schema.Text(title=u"Details",
                          required=False)

class View(dexterity.DisplayForm):
    """The view. May will a template from <modulename>_templates/view.pt,
    and will be called 'view' unless otherwise stated.
    """
    grok.require('zope2.View')
    grok.context(IPage)

class Edit(dexterity.EditForm):
    """A standard edit form.
    """
    grok.context(IPage)

    def updateWidgets(self):
        super(Edit, self).updateWidgets()
        self.widgets['title'].mode = 'hidden'

这些形式的摸索方式与 plone.directives.form,并支持自定义模板关联。拜托 但是,请注意:

  • 使用dexterity.AddForm作为基时,必须使用grok.name() 指令来指定添加视图的名称。通常,这和 工厂类型信息对象的名称。
  • 使用dexterity.EditForm作为基时,必须使用grok.context() 并提供一个灵活的内容类型接口作为参数。这是为了 允许正确重用类型。

更改日志

1.0.2-2011年9月25日

  • 在^{tt5}中修复super()调用$ [大卫萨格里]

1.0.1-2011年9月24日

1.0-2011年5月20日

  • 修好休息。 [大卫萨格里]

1.0b1-2010-08-05

1.0a2-2009年11月17日

  • 修复Zope2.12上的弃用警告 [选项]

1.0A1-2009-07-25

  • 初始版本

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java提高机器学习Rest服务性能   java反转字符的字符串顺序,并使用构造函数将其放入LinkedList   继承为什么Java不支持在方法签名中添加“throws”?   执行DDL alter table if exists任务时发生java错误。城市   java在eclipse中使用CREATETXT并打包在jar中   java AES256与3DES 256密钥检测   具有两个相同类型字段的java JPA实体   java Webapp日志记录设置被忽略   java KeyEventDispatcher可以在一个应用程序中工作,但不能在另一个应用程序中工作   带有Swing和OpenJDK的java PinchZoom   未涉及java AspectJ注释切入点(对于任何注释类型)   java如何在FuseBAI中获取日志文件详细信息   java在Linux上将wstring转换为jstring