Hi, Am Freitag, den 31.08.2007, 13:06 +0200 schrieb Wichert Akkerman: > Is there documentation on sources anywhere? The last time I checked > there was nothing that I could understand either in zope.* or > on the wiki.
It took me a while to understand them myself. Especially as there is some code in there that is basically not useful. I'll try to give a very short overview: Sources are designed with three concepts: - The source itself - an iterable This can return any kind of object it wants. It doesn't have to care for browser representation, encoding, ... - A way to map a value from the iterable to something that can be used for form *values* - this is called a token - A way to map a value to something that can be displayed to the user - this is called a title The last two elements are dispatched using a so called `term`. The ITitleTokenizedTerm interface contains a triple of (value, token, term). Additionally there are some lookup functions to perform the mapping between values and terms and tokens and terms. Sources that require context use a special factory: a context source binder that is called with the context and instanciates the source when it is actually used. The general design is very nice as it seperates the concerns correctly, for simple use cases it requires you to write quite a few components (3 classes most times) which is why I came up with zc.sourcefactory which basically provides a cleaner easy-to-use API for (as the name says) application developers while having the backend APIs be logically sound. Hope this helped, Christian _______________________________________________ Zope3-dev mailing list Zope3firstname.lastname@example.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com