灵活的访问器和修改器方法
我是敏捷的初学者(大约 2 天了)。我正在尝试在迁移网站的过程中将旧的内容类型迁移到灵活的内容。
经典原型中的模式定义就像
TextField('script',
searchable=0,
mutator="write",
accessor="__call__",
edit_accessor="document_src",
widget=TextAreaWidget(label="Page Template script",rows=40,cols=40),
如何灵活地重新定义?我正在从 Plone 252 升级到 Plone 412。
问候,
I'm beginner user of dexterity (about 2 days now). I'm trying to migrate my old content type to dextertiy content in process of migrating website.
Schema defination in classic archetype is like
TextField('script',
searchable=0,
mutator="write",
accessor="__call__",
edit_accessor="document_src",
widget=TextAreaWidget(label="Page Template script",rows=40,cols=40),
How can I redefine in dexterity ? I'm upgrading from Plone 252 to Plone 412.
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须从头开始创建一个新的 Dexterity 内容类型,并将 Archetype 的架构完全重写为继承自 plone.directives.form 并具有 zope.schema 字段类型的新架构。
欲了解更多信息,请参见此处:
http://plone.org /products/dexterity/documentation/manual/developer-manual/schema-driven-types/referencemanual-all-pages
例如,您的 Archetype 的架构字段声明将类似于就像 Dexterity 中的这样:
Dexterity 内容类型不会像 Archetypes 内容类型那样获得自动访问器和修改器。相反,您只需访问架构字段,就像它是一个属性一样。
例如:
如果您想创建相同的访问器和修改器(就像您在 Archetypes 字段中指定的那样),则必须在 Dexterity 类上手动创建它们。
例如,类似:
You will have to create a new Dexterity content type from scratch and completely rewrite your Archetype's Schema to a new schema that inherits from plone.directives.form and with the field types form zope.schema.
For more information, see here:
http://plone.org/products/dexterity/documentation/manual/developer-manual/schema-driven-types/referencemanual-all-pages
For example, your Archetype's schema field declaration, will look like something like this in Dexterity:
Dexterity content types don't get automatic accessors and mutators like Archetypes content types. Instead, you just access the schema field as if it's an attribute.
For example:
If you want to create the same accessors and mutator (like you specified in the Archetypes field), you'll have to create them manually on your Dexterity class.
For example, something like: