[Grok-dev] Entity Relations and Forms

Martijn Faassen faassen at startifact.com
Fri Aug 22 20:57:50 EDT 2008


My apologies that nobody replied to you for so long. We organize a 
"reply group" that makes sure every posting to the list (except spam!) 
gets a reply!

rmoskal wrote:
> I'm new to Grok (and Zope 3). 


> ... I could accomplish the same thing by creating a
> vocabulary out the my container full of Contributors.
> Which method is preferable? What's the common pattern for doing something
> like this?

I think the best library to look at is zc.sourcefactory:


you can include this as a dependency in your project's setup.py. Perhaps 
you may want to lock it down to a particular version in a [versions] 
list in buildout.cfg as well.

You'd use it something like this:

class IFoo(Interface):
     contributor = schema.Choice(

Off the top of my head, your ContributorSource could be implemented 
something like this:

class ContributorSource(BasicSourceFactory):
    def getValues(self):
        # assuming 'contributors' is a subfolder in your site...
        return grok.getSite()['contributors'].values()

    def getTitle(self, value):
        return value.name_attributge_of_contributor

A late answer, but I hope this helps!



More information about the Grok-dev mailing list