Using the config file to get shorter tagged values
Some tagged values' values can get quite lengthy. If you use such a lengthy value a few times, you can store it in your project's config file.
An example of long tagged values are the permissions you set on workflow states. A key view with value Manager, Member, Reviewer for instance.
In tagged values, the text you type in is normally taken as a string. If you prefix your value with python:, it is copy-pasted literally into your code. So python:["a", "b"] is put into your code as ["a", "b"].
The config file
ArchGenXML generates a config.py in your Product's root directory, which in turn tries to import AppConfig.py. So stuff you put in there is treated as if it is placed in the main config file. Here's a quick example:
UNWANTED_CONTENT_TYPES = ['News Item',
'Link',
'Topic'
]
# STYLESHEET_TYPES is used for registering stylesheets.
STYLESHEETS = [{'id': 'newsitem.css',
'expression':
'python:object.getTypeInfo().getId() == "Newsitem"'},
{'id': 'documentplus.css',
'expression':
'python:object.getTypeInfo().getId() == "DocumentPlus"'},
{'id': 'internetproducts.css'},
]
JAVASCRIPTS = [{'id': 'hideShow.js',
'expression': 'python:object.getTypeInfo().getId() == "Pressrelease"'}]
Every ArchGenXML-generated file contains an import like from Products.YourProduct.config import *, so the variables defined in your AppConfig are directly available in all the files. This means that you can specify shortcuts for the tagged values.
Shorter tagged values
Example line in your 'AppConfig.py':
EDITORLIST = 'Manager, Member, Reviewer'
Remember that we can use python: to paste raw python code directly into the generated files. After adding above line, the original tagged value view with value Manager, Member, Reviewer can be shortened to the tagged value view with value python:EDITORLIST. Now that's handy :-)
Note: After typing this I noticed there's no from Products.YourProduct.config import * in the workflow script... It's added to svn now, so versions after 1.4.0 will include it. But you can use the general technique in many other places, though.