Re: Dexterity DataGridField Default Factory

Sean Upton <[email protected]>
Newsgroups gmane.comp.web.zope.plone.user
Message-ID <CANjV-2MWpW3LJnMHnyFGGjRCpV5MQa44tdYBW5ZKzWArPau2og@mail.gmail.com>
On Mon, Mar 2, 2015 at 7:32 AM, Simon Richardson <[email protected]>
wrote:

> Hi Plone users
>
> I'm unable to create a default factory for a datagridfield field, due to
> running into a
>

What type is your defaultFactory callable returning?  I am assuming that it
should be a list of dict, assuming you are using value_type=DictRow in your
schema field.


> 'unhashable type: list' error
>

Does your defaultFactory callable suffer from this problem if you call it
in a vacuum?


>
> Does anyone have an example of a datagridfield with a default value
> defined?
>

I have no working example (I don't use defaults in any of my grids), but
assume something like this might work (untested):

def myTableDefault():
    #return []  # simplest case
    some_record = {'title': u'This', 'description': u'That', 'count': 1}
    return [some_record]

class IMyRowSchema(model.Schema):
    title = schema.TextLine()
    description = schema.Text()
    count = schema.Int()

class IMySchema(model.Schema):

    form.widget(table=DataGridFieldFactory)
    myfield = schema.Llst(
        value_type=DictRow(schema=IRowSchema),
        defaultFactory=myTableDefault
        )
  <http://goparallel.sourceforge.net/>


Sean

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/

_______________________________________________
Plone-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plone-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.