怎样用内容类型来解决问题? 在我们深入Dexterity前,值得好好考虑下在plone中用内容类型来作开发的解决方案。如果你熟悉 Archetypes基本的开发,并且也熟悉 Grok 或者是 Zope 3, 那么问题很好理解。 Plone 用 ZODB,一种对象数据库来取代关系数据库来作为缺省的内容存储。ZODB十分适合象网页这样异构的较少结构化的内容的存储。 在Plone中的内容类型要么containers 要么是 items (this distinction is sometimes called folderish vs. non-folderish)。一个一对多的关系典型被映射为 container (the "one") containing many items (the "many"), 尽管也可以用 references 跨越内容层次实现一对多。 每个类型有一个schema – 一个配合有相关属性(如title,default value, constraints, and so on)的字段集。 这个 schema 是用来生成表单,并且用来描述该类型的实例。此外,对于 schema-driven 的表单,典型的有一个或多个视图,这些视图都是安全敏感的,(如 add permissions, or per-field read/write permissions) ,也是工作流化的。 当我们在plone中试图解决一个特定的内容管理的问题时,我们将设计新的内容类型。本教程的实例将建立一个简单的内容集合帮助组织会议。 We want to manage a program consisting of multiple sessions. Each session should be listed against a track, have a time slot, a title, a description and a presenter. We also want to manage bios for presenters. 有多种方法可以实现这个,下面是其中一种可能的方式:
A content type Presenter is used to represent presenter bios. 字段包括 name, description 和 professional experience.
A content type Program represents a given conference program. Besides some basic metadata, it will list the available tracks.这个类型是 folderish.
A content type Session represents a session. Sessions can only be added inside Programs. A Session will contain some information about the session, and allow the user to choose the track and associate a presenter.