At the Forge - CMF Types
Over the last few months, we have discussed content management systems (CMS) in general and Zope's content management framework (CMF) in particular. Zope's CMF is designed to give developers the tools they need to create their own content management systems. Of course, anyone who has worked with a CMS knows that even the most proprietary of the bunch requires extensive modification, reworking and customization before it can be used. Zope thus not only reduces the price of the base software, but provides a rich environment that makes it relatively easy to develop and customize the CMS.
When you create a CMF site, you (as the site manager) can add, modify and delete documents. Click on the folder contents link, click on the New... button, indicate which type of document you want to add and what ID it should have and then click on the add button. Enter the metadata (that is, title, description, subject and content type), click on the change & edit button, add some content and you're off and running.
However, although the existing content types are sufficient for simple sites, more sophisticated sites will want to create their own, custom types. CMF provides several ways to do exactly this. This month, we look at types in CMF—how we can work with them, customize their behavior, install new ones and even create new types to handle custom content.
The simplest way to create a new type is to use CMF's built-in, Web-based type extension system. It allows you to create a new type that shares its methods, properties, actions, presentation templates and icons with another type by default. When you create a new type using the Web-based extension system, you can modify any of these items, except for the methods and properties. In other words, the new type you create can have a different look and feel from its parent type, but it continues to behave much as the parent did.
For example, let's go to what is known as the types tool, available by clicking on portal_types within the management interface for a CMF site. If you don't have a CMF site already defined in Zope, you can create one by choosing CMF Site from the Add... menu in the upper-right corner of the Web-based Zope management interface. Once you have created the site, clicking on its icon from within the management interface displays a number of different customization tools, each with an icon that looks like a wrench.
When you first enter the types tool, you see a list of the currently defined CMF types, including folders, documents, news items, links and topics. You can examine and modify the properties and actions associated with these types by clicking on the name of the type you want to change. For example, if you want to examine or change the way the File content type does things, click on File. This brings up a new set of management tabs at the top of the page, with properties (the default) and actions being the only ones not standard to other parts of Zope. Actually, properties is a standard Zope tab, but CMF types have a number of unusual property names.
In addition to the standard properties you expect to see, each type has the following properties that affect what it does:
Icon: a string that describes which icon should be displayed for items of this type.
Product metatype: describes the Zope product meta-name. Meta-names are used in the Add... menu in the Zope Management Interface. This also is the name used in the similar Add... menu in the CMF.
Product name: indicates the Zope product in which the CMF type was defined. Because both the File and News item types were defined in the default CMF installation, they are listed as being in the CMFDefault product. And indeed, if you look in /lib/python/products/CMFDefault, which is a symbolic link to CMF-1.3/CMFDefault in CMF 1.3, you should see both File.py and NewsItem.py, Python modules that define the content types. To see how the initial values for properties are set, look at the factory_type_information variable in any module for any defined CMF type.
Product factory method: describes the method CMF should invoke to create a new instance of the type.
Filter content types and Allowed content types: these work together, even though they are separate properties. Although both of these properties exist for all CMF types, they are relevant only for folder-like objects, such as Folders and Topics. The first, Filter content types, is a boolean value that indicates whether Allowed content types is active. The second, Allow content types, lets you specify which types may be contained within the current type. So if you were interested in creating a folder that would contain only News items, you could do so by clicking yes and then indicating which types may be included.
|Using Django and MongoDB to Build a Blog||Mar 05, 2014|
|What virtualization solution do you use/manage at work?||Mar 04, 2014|
|Our Assignment||Mar 04, 2014|
|March 2014 Issue of Linux Journal: 20 Years of Linux Journal||Mar 03, 2014|
|Have Resume - Will Travel||Feb 28, 2014|
|March 2014 Video Preview||Feb 28, 2014|
- Using Django and MongoDB to Build a Blog
- Our Assignment
- Sign Up to Win a Silicon Mechanics Swag Pack!
- March 2014 Issue of Linux Journal: 20 Years of Linux Journal
- RSS Feeds
- Linux Systems Administrator
- Have Resume - Will Travel
- Senior Perl Developer
- Technical Support Rep
- Zedge, for All Your Annoying Ringtones!
- You have to be careful there
1 week 2 days ago
- Wonder when LJ is going to
1 week 3 days ago
- Puerto Rico Free Software
1 week 4 days ago
1 week 5 days ago
- I hate voice commands
1 week 6 days ago
- usabilty --- AGAIN with this nonsense
1 week 6 days ago
- Don't make excuses
1 week 6 days ago
- Sorry to let you know, but
1 week 6 days ago
- Ridiculous statement. Not a
2 weeks 9 hours ago
2 weeks 13 hours ago