创建灵巧内容的类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 WebClient请求级别超时抛出名为default onErrorDropped的运算符   java JAXB外部绑定文件错误   Freemarker中的java转义宏参数值   java正在同步来自不同对象{已编辑}的线程   java如何在另一个类上更新活动中的元素   java Hibernate连接查询   java可以使用Apache Crunch创建类似于图形的数据结构吗?   java在JLabel的开头加上3个点   java 安卓应用程序显示线程错误   java@RequestBody在Spring中总是空的   java Android异步任务永远不会结束   具有多个属性的java Jaxws枚举   java中的安卓 Stripe InvalidRequestException   多线程java。util。非多线程程序中的ConcurrentModificationException   Minecraft Java插件如何删除HashMap中存储的所有块   空Java字符串的大小   从AJP连接器请求检索Shibboleth属性的java   oracle11g将Java类文件加载到Oracle数据库