Hello...

I'm repeating myself here, and I apologise, but I'm not able to figure this
out, yet.

I've created a collection in python code, and I want to initialise it.  In
archetypes.querywidget/field.py, in QueryField/set(), I read this:
        """
        The passed in object should be a records object, or a sequence of
        dictionaries
        """

So in my code I've done this:

obj.setQuery([{'i': 'Type', 'o':
'plone.app.querystring.operation.selection.is', 'v': 'Service'}])

I've also tried this:

obj.query = [{'i': 'Type', 'o':
'plone.app.querystring.operation.selection.is', 'v': 'Service'}]

But when I go to the edit tab on my new collection, I get this traceback:

   - URL:
file:/home/cb/Plone/zinstance/src/archetypes.querywidget/archetypes/querywidget/skins/querywidget/querywidget.
pt
   - Line 40, Column 36
   - Expression: <PythonExpr indexes[row.i]['title']>
   - Names:
      {'container': <PloneSite at /Plone>,
       'context': <Collection at /Plone/services>,
       'default': ,
       'here': <Collection at /Plone/services>,
       'loop': {u'field': <Products.PageTemplates.Expressions.PathIterator
object at 0xc49bbcc>,
                u'fieldset':
<Products.PageTemplates.Expressions.PathIterator object at 0xc49b60c>,
                u'row': <Products.PageTemplates.Expressions.PathIterator
object at 0xc5120ec>},
       'nothing': None,
       'options': {'args': (),
                   'state':
<Products.CMFFormController.ControllerState.ControllerState object at
0xbfddbec>},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at
0xae561bc>,
       'request': <HTTPRequest,
URL=http://localhost:8080/Plone/services/atct_edit>,
       'root': <Application at >,
       'template': <FSControllerPageTemplate at /Plone/atct_edit used for
/Plone/services>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'admin'>}
  Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
   - __traceback_info__: indexes[row.i]['title']
  Module PythonExpr, line 1, in <expression>
AttributeError: 'dict' object has no attribute 'i'

What does the set() function's doc string mean, when it says "a records
object"?

I can't find any examples of how this is done, outside of the p.a.collection
tests, and there, a list of dictionaries is used just like mine.  If I
manually create a collection, and modify querywidget.pt to simply print the
row, it appears as a list of dictionaries, exactly like mine.

Any pointers, please... ?

-- 
View this message in context: 
http://plone.293351.n2.nabble.com/plone-app-collection-and-archetypes-querywidget-initialisation-in-python-code-tp5841090p5841090.html
Sent from the Product Developers mailing list archive at Nabble.com.
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to