FOSElasticaBundle - Symfony - symfony

When I try to access my search page, I got this error.
It works on my local machine but not on the server I got the error below.
Any idea of what might be causing this error?
[2017-09-14 11:49:57] request.CRITICAL: Uncaught PHP Exception
RuntimeException: "Cannot find corresponding Doctrine objects (0) for
all Elastica results (21). IDs: 35, 42, 47, 54, 59, 61, 66, 73, 112,
117, 124, 129, 24, 31, 36, 43, 50, 62, 67, 106, 113" at
/srv/www/ribambel.com/httpdocs/server/vendor/friendsofsymfony/elastica-bundle/Doctrine/AbstractElasticaToModelTransformer.php
line 90 {"exception":"[object] (RuntimeException(code: 0): Cannot find
corresponding Doctrine objects (0) for all Elastica results (21). IDs:
35, 42, 47, 54, 59, 61, 66, 73, 112, 117, 124, 129, 24, 31, 36, 43,
50, 62, 67, 106, 113 at
/srv/www/ribambel.com/httpdocs/server/vendor/friendsofsymfony/elastica-bundle/Doctrine/AbstractElasticaToModelTransformer.php:90)"}
[]
I've searched on the internet and most of the answers that I got was
to run the populate command but it did not work.
And some research lead me to this one.
elastica_to_model_transformer:
ignore_missing: true
When I run the php "app/console fos:elastica:populate":
On my Local Machine:
Resetting search 0/336 [>---------------------------] 0%
%message%
100/336 [========>-------------------] 29%
Populating search/webediacontent
200/336 [================>-----------] 59%
Populating search/webediacontent
300/336 [=========================>--] 89%
Populating search/webediacontent
336/336 [============================] 100%
Populating search/webediacontentRefreshing search
Refreshing search
On server:
Resetting search
124/124 [============================] 100%
Populating search/webediacontentRefreshing search
Refreshing search

Related

pyautogui.screenshot() at the same screen with diferent pixels

I use pyautogui to write the auto-gui test tool for Debian9 desktop application written by Qt5.9.2. The background of application was filled with many PNG images by qss. I capture the screenshot by pyautogui.screenshot() and compare the pixels by pyautogui.getpixel(). I found the sceenshots captured by pyautogui.screenshot() may be slightly different with 1 pixel, such as:
Different image at pos[528, 1228], pixel1[21, 21, 22], pixel2[21, 21, 24]
Different image at pos[528, 1414], pixel1[94, 94, 94], pixel2[93, 93, 93]
Different image at pos[529, 1414], pixel1[94, 94, 94], pixel2[93, 93, 93]
Different image at pos[530, 1414], pixel1[94, 94, 94], pixel2[93, 93, 93]
Different image at pos[531, 1414], pixel1[94, 94, 94], pixel2[93, 93, 93]
Different image at pos[812, 1225], pixel1[55, 55, 55], pixel2[54, 54, 54]
Different image at pos[812, 1228], pixel1[23, 23, 24], pixel2[23, 23, 25]
Different image at pos[812, 1229], pixel1[13, 13, 14], pixel2[12, 13, 14]
Different image at pos[812, 1230], pixel1[13, 13, 14], pixel2[13, 13, 15]
I don't know it's casused by Qt or pyautogui.
Updated
I find the same question without the convinced answer.

zope.schema List - Save List of lists

did i misunderstand something? I want to save a list of lists, or a set of lists....
I have this
fcurricula = schema.List(
title=_(u'Curricula'),
required=False)
I tried to save this:
[
[261, u'26-BEA', 138, 4, u'h\xf6ren, listen', 4.00, 0, u'655755sa939b9b10'],
[261, u'26-BEA', 138, 4, u'h\xf6ren, listen', 4.00, 0, u'655755sa939b9b10']
]
But I get following error
Module zope.tales.expressions, line 217, in __call__
Module Products.PageTemplates.Expressions, line 155, in _eval
Module Products.PageTemplates.Expressions, line 117, in render
Module dudal.db.browser.dbimport, line 216, in dudal_fcurricula_import
Module plone.registry.registry, line 47, in __setitem__
Module plone.registry.record, line 83, in _set_value
Module zope.schema._bootstrapfields, line 182, in validate
Module zope.schema._field, line 475, in _validate
Module zope.schema._bootstrapfields, line 309, in _validate
Module zope.schema._bootstrapfields, line 248, in _validate
Module zope.schema._bootstrapfields, line 233, in _validate
Module zope.schema._bootstrapfields, line 209, in _validate
WrongType: ([[261, u'26-BEA', 138, 4, u'h\xf6ren, listen', 4.0, 0, u'655755sa939b9b10'], [261, u'26-BEA', 138, 4, u'h\xf6ren, listen', 4.0, 0, u'655755sa939b9b10']], <type 'set'>, 'value')
You need to define the value_type of the list elements. In you case also a list--> nested list.
You may try something like this:
fcurricula = schema.List(
title=_(u'Curricula'),
required=False)
value_type=schema.List(...)
But I don't know if there is a widget for this use case.
From my point of view, the right widget for you ist a datagrid widget.
--> https://github.com/collective/collective.z3cform.datagridfield
It stores a list of dictionaries.
If you can properly name the columns in your nested list, you can use a List field with value_type="DictRow" with a datagridwidget.
Since you have to define a seperate schema you can also make sure, your list contains valid data.

non required SelectFieldWidget

I have a dexterity content type and I'd like to have a Select-Field which is not required and which values came from a vocabulary.
This is the vocabulary:
#grok.provider(IContextSourceBinder)
def voc_test(context):
values = range(10, 21)
terms = map(lambda x: SimpleTerm(value=str(x),
title=str(x)), values)
return SimpleVocabulary(terms)
And this the definition of the field:
from plone.directives import dexterity, form
from plone.namedfile.field import NamedImage
from zope import schema
class IMyType(form.Schema):
...
form.widget('test', SelectFieldWidget)
test = schema.List(
title=_(u"Test"),
value_type=schema.Choice(source=vocabularies.voc_test),
description=_(u"desc_test"),
required=False,
)
What I get is a select field with my values from the vocabulary and the first value is 'No Value'. That is fine. But when I hit save and have 'No Value' selected a error message is shown:
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module plone.z3cform.layout, line 66, in __call__
Module plone.z3cform.layout, line 50, in update
Module plone.dexterity.browser.edit, line 52, in update
Module plone.z3cform.fieldsets.extensible, line 59, in update
Module plone.z3cform.patch, line 30, in GroupForm_update
Module z3c.form.group, line 145, in update
Module plone.app.z3cform.csrf, line 21, in execute
Module z3c.form.action, line 98, in execute
Module z3c.form.button, line 315, in __call__
Module z3c.form.button, line 170, in __call__
Module plone.dexterity.browser.edit, line 23, in handleApply
Module z3c.form.group, line 98, in extractData
Module z3c.form.form, line 147, in extractData
Module z3c.form.field, line 303, in extract
Module z3c.form.converter, line 316, in toFieldValue
Module z3c.form.term, line 41, in getValue
Module z3c.form.term, line 38, in getTermByToken
Module zope.schema.vocabulary, line 133, in getTermByToken
LookupError: --NOVALUE--
If I change:
required=False,
to
required=True
saving works.
Hopefully someone can help. Thanks.
Set a default that is within your vocabulary and make the field required so that "--NOVALUE--" is not in the options.
If, for some reason, you want to use "-- NOVALUE --" for that default, then add it to the vocabulary. If the field is set required, it will not be duplicated.

Vocabulary do not work on collective.z3cform.datagridfield's sub object schema because of the context is NO_VALUE

I'm working on a content type that uses datagridfield.
Within the subobject, I have a choice field with a custom vocabulary.
The vocabulary work outside the datagrid (If I use it directly in the content type's schema). But when I add it to the subobject, it doesn't work anymore.
Looking at the debug note, I see the vocabluary's context is NO_VALUE.
Any hint/direction to make this works ?
This is the simplest schema that won't work (I think):
# Import
from zope import schema
from zope.interface import Interface
from plone.directives import form
from collective.z3cform.datagridfield import DataGridFieldFactory, DictRow
# The container
class IMenu(Interface):
dishes = schema.List(value_type=schema.TextLine())
# The vocabulary
#grok.provider(IContextSourceBinder)
def getDishes(context):
terms = [SimpleVocabulary.createTerm(dish, dish, dish) for dish in context.dishes]
return SimpleVocabulary(terms)
# The object line
class IOrderLine(Interface):
dish = schema.Choice(source=getDishes)
quantity = schema.Int()
# The object
class IOrder(Interface):
form.widget(dishes=DataGridFieldFactory)
dishes = schema.List(value_type=DictRow(schema=IOrderLine))
Now I register Menu, Order as dexterity content type, add a menu and tried to add an order within it, I got an error on Order add view and this is the traceback:
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall
Module ZPublisher.Publish, line 46, in call_object
Module plone.z3cform.layout, line 66, in __call__
Module plone.z3cform.layout, line 50, in update
Module plone.dexterity.browser.add, line 112, in update
Module plone.z3cform.fieldsets.extensible, line 59, in update
Module plone.z3cform.patch, line 30, in GroupForm_update
Module z3c.form.group, line 128, in update
Module z3c.form.form, line 134, in updateWidgets
Module z3c.form.field, line 277, in update
Module z3c.form.browser.multi, line 63, in update
Module z3c.form.browser.widget, line 171, in update
Module z3c.form.widget, line 477, in update
Module collective.z3cform.datagridfield.datagridfield, line 107, in updateWidgets
Module collective.z3cform.datagridfield.datagridfield, line 91, in getWidget
Module z3c.form.browser.widget, line 171, in update
Module z3c.form.object, line 217, in update
Module z3c.form.object, line 208, in updateWidgets
Module z3c.form.object, line 87, in update
Module plone.z3cform.patch, line 21, in BaseForm_update
Module z3c.form.form, line 150, in update
Module z3c.form.form, line 134, in updateWidgets
Module z3c.form.field, line 277, in update
Module z3c.form.browser.select, line 51, in update
Module z3c.form.browser.widget, line 171, in update
Module z3c.form.widget, line 220, in update
Module z3c.form.widget, line 214, in updateTerms
Module zope.component._api, line 107, in getMultiAdapter
Module zope.component._api, line 120, in queryMultiAdapter
Module zope.component.registry, line 238, in queryMultiAdapter
Module zope.interface.adapter, line 532, in queryMultiAdapter
Module z3c.form.term, line 96, in ChoiceTerms
Module zope.schema._field, line 349, in bind
Module waga.game.core.content.interfaces, line 202, in getDishes
AttributeError: 'NO_VALUE' object has no attribute 'dishes'
> /home/quyetnd/Projects/waga.game.core/src/waga/game/core/content/interfaces.py(202)getDishes()
-> terms = [SimpleVocabulary.createTerm(dish, dish, dish) for dish in context.dishes]
The context object is an instance.
This is limitation in z3c.form (at least some versions, I think it has been fixed in the newer ones).
My ugly workaround in vocab source function:
if not context:
context = getSite()
if not context:
# Form is rendered from console without HTTP request traversing, etc.
# and thread local site variable is not set
raise RuntimeError("Oh snap. Beer time.")
...
http://developer.plone.org/serving/traversing.html#using-getsite

tile edit view wrong context for vocabularies

I have a persistent tile that has a choice field:
subjects = schema.List(
title=_(u"Subjects"),
value_type=schema.Choice(
vocabulary='my.subjects'
),
)
but this is failing on edit view rendering like this:
2013-05-22 18:37:56 ERROR Zope.SiteErrorLog 1369240676.330.546121806344 http://localhost:8082/plumi/##edit-tile/tagcloud.tile/home-cloud
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module plone.z3cform.layout, line 70, in __call__
Module plone.z3cform.layout, line 54, in update
Module plone.app.tiles.browser.edit, line 48, in update
Module plone.app.tiles.browser.base, line 55, in update
Module plone.z3cform.fieldsets.extensible, line 59, in update
Module plone.z3cform.patch, line 30, in GroupForm_update
Module z3c.form.group, line 125, in update
Module plone.app.tiles.browser.base, line 71, in updateWidgets
Module z3c.form.field, line 275, in update
Module z3c.form.browser.orderedselect, line 50, in update
Module z3c.form.browser.widget, line 70, in update
Module z3c.form.widget, line 199, in update
Module z3c.form.widget, line 193, in updateTerms
Module zope.component._api, line 107, in getMultiAdapter
Module zope.component._api, line 120, in queryMultiAdapter
Module zope.component.registry, line 238, in queryMultiAdapter
Module zope.interface.adapter, line 532, in queryMultiAdapter
Module z3c.form.term, line 174, in CollectionTerms
Module zope.schema._field, line 352, in bind
Module Zope2.App.schema, line 33, in get
Module my.vocabularies, line 22, in __call__
Module Products.CMFCore.utils, line 10, in check_getToolByName
Module Products.CMFCore.utils, line 120, in getToolByName
AttributeError: portal_catalog
This happen because the context passed to the vocabulary call is the data dictionary of the tile. It happens also when using SearchableTextSourceBinder in another field:
source=SearchableTextSourceBinder(
{'is_folderish': True},
default_query='path:'
)
that makes plone.app.vocabularies.catalog fail:
Module plone.app.vocabularies.catalog, line 237, in __call__
Module plone.app.vocabularies.catalog, line 144, in __init__
Module Products.CMFCore.utils, line 10, in check_getToolByName
Module Products.CMFCore.utils, line 120, in getToolByName
AttributeError: portal_catalog
I don't know, if it's by design, but when a persistent tile is edited, context sensitive vocabulary will get its context (persistent tile data dictionary) without any acquisition wrapping. Therefore all lookups which rely on acquisition will fail.
You could try fixing your vocabulary to use portal root as its context for getToolByName-looksup using either plone.api.portal.get() or zope.component.hooks.getSite().
If you really need the current context, an ugly way would be to get zope.globalrequest.getRequest().get("PUBLISHED") which should be the current publishable context found by ZPublisher. It's usually a view, but you can get your context object from its acquisition chain. Of course, you should be very defensive with that approach.

Resources