[Zope-dev] Fun with vocabularies

Charlie Clark charlie.clark at clark-consulting.eu
Thu Oct 7 08:21:56 EDT 2010


Hi,

I was wondering whether it's possible to use callables for schema  
vocabularies without registering them first?
ie.

def my_vocab(context):
	while some_constraint:
		yield zope.schema.SimpleTerm()
alsoProvides(my_vocab, zope.schema.interfacesIBaseVocabulary)

class IMySchema(Interface):

	value = Choice(
		vocabulary=my_vocab
			)

I'm sure it should be possible but my weak and feeble brain has somehow  
failed to solve the puzzle!

On a similar note: how should I handle i18n message objects that are the  
title of a SimpleTerm? At least in zope.formlib this leads to a rendering  
error because: "AttributeError: 'MessageFactory' object has no attribute  
'replace'"

Thanks for any pointers.

Charlie
-- 
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226


More information about the Zope-Dev mailing list