[Grok-dev] Entity Relations and Forms

Jeroen Michiel jmichiel at yahoo.com
Wed Jan 21 09:25:34 EST 2009


Sorry, my bad, it seems there was a problem in my code that gave the same
error on the 0.3.5.
I didn't specify a getToken function in my source class, and it gave the
scary error.

This is my app.py:

import grok
from zope.interface import Interface
from zope import schema
import zc.sourcefactory.basic

class Test(grok.Application, grok.Container):
    pass

class Index(grok.View):
    pass # see app_templates/index.pt


@grok.subscribe(Test, grok.IObjectAddedEvent)
def added(app, event):
     app['data'] = grok.Container()
     app['data']['0']='test'
     app['data']['1']='one'
     app['data']['2']='two'
     app['data']['3']='three'


class TestSource(zc.sourcefactory.basic.BasicSourceFactory):
    def getValues(self):
        return grok.getSite()['data'].values()

    def getTitle(self, value):
        return value
    
    def getToken(self, value):
        return value

class ITestData(Interface):
    select = schema.Choice(source = TestSource(), title=u'Testing')
    
class Add(grok.AddForm):
    grok.context(Interface)
    form_fields = grok.Fields(ITestData)


Setting zc.sourcefactory to 0.4.0, zope.app.form to 3.7.0 and zope.schema to
3.5a1 makes it work, now!
I don't know whether this might break something else, however...
-- 
View this message in context: http://www.nabble.com/Entity-Relations-and-Forms-tp19014121p21584120.html
Sent from the Grok mailing list archive at Nabble.com.



More information about the Grok-dev mailing list