The usecase: I wanted to populate a folder with some 300 links and I wanted to do it using genericsetup. It is a custom ATFolder subclass with ATLink subclasses in there. The links can be searched using categories, using full-text search and by first letter of the title. That's why we're calling it an AzLinkFolder: a..z.
I wanted to try out genericsetup, which has a handy way of adding content to your site. In your products, add a profiles/default/structure folder and place your content in there. If it is a folder, add the folder and in a file called .objects, tell what type you want it to be:
That's pretty simple. Add the same type of lines for other content you're creating. OK, now to the link folder contents. That are links which have an id, a title and a remote url that they're pointing to. Now that's a problem. With core genericsetup, you can add links OK. Add them to a .objects with link001,AzLink and so; add folders named link001 and so and put a file .properties in there with something like this in there:
[DEFAULT] description = title = Philips Research Europe
I tried putting externalUrl in there, but no avail. Alec Mitchell helped me by saying it wasn't currently possible and he gave me an alternative solution that did work.
The core solution is to use so-called rfc822 marshalling. For that to work with genericsetup, you need to tag your contenttype with IDAVAware. So in my AzLinks.py:
.... from zope import interface from Products.GenericSetup.interfaces import IDAVAware .... class AzLink(....): interface.implements(IDAVAware) ....
From that moment on, your contenttype doesn't listen to the normal .properties file format anymore. You need a file formatted like the following:
id: link200 title: Research International (corporate) on pww Content-Type: text/plain http://pww.research.philips.com/corporate/index.html
Note the content-type line and the empty line below it: the actual URL is apparently the main content of an ATLink. To discover how to format your files, just append manage_FTPget, so ..../azlinks/link300/manage_FTPget. That gives you all the info you need.
I had to create some 300 files like this (generated from a comma separated file, I'm not typing all that in by hand!). Inside the profiles/default/structure/azlinks/ folder where I placed them there was one more thing to do: add a .objects file (of course):
... link318,AzLink link319,AzLink link320,AzLink ...
My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):