Erro ao tentar criar objetos de conteúdos via scripts externos no IDG
claytonc opened this issue · comments
Qual versão do produto você está usando e em qual sistema operacional?
Para o testes foi utiliza a última versão do IDG 1.x.
Não foram efetuados testes na versão 2.x por problemas no buildout, sempre ocorre o mesmo erro de webpack somente no brasil.gov.tiles e brasil.gov.agenda.
Possui plugins adicionados além dos definidos numa instalação padrão do Portal Padrão?
Não
Está utilizando o buildout padrão como o usado em https://github.com/plonegovbr/portal.buildout?
Sim e sem modificações para o teste, no 1.x
Está utilizando o arquivo de versões de pinagens das dependências como definido em https://github.com/plonegovbr/portalpadrao.release e https://github.com/plonegovbr/brasil.gov.portal#requisitos?
Sim, do branch
Quais são os passos para reproduzir o problema?
$ ./bin/instance debug
1 -
>>> portal = app.Plone
>>> portal.invokeFactory('Document', 'document')
2 -
>>> from plone import api
>>> obj = api.content.create(type='Document',
... title='document',
... container=app.Plone)
3 -
>>> from plone.dexterity.utils import createContentInContainer
>>> item = createContentInContainer(app.Plone, "Document", title="document")
Qual é o retorno esperado? O que você vê ao contrário do esperado?
Conteúdo criado
A aplicação forneceu algum erro no console ou na interface?
1- invokeFactory
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/PortalFolder.py", line 292, in invokeFactory
return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/TypesTool.py", line 833, in constructContent
ob = info.constructInstance(container, id, *args, **kw)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/TypesTool.py", line 311, in constructInstance
return self._constructInstance(container, id, *args, **kw)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/TypesTool.py", line 564, in _constructInstance
factory = getUtility(IFactory, self.factory)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 169, in getUtility
raise ComponentLookupError(interface, name)
ComponentLookupError: (<InterfaceClass zope.component.interfaces.IFactory>, 'Document')
2 - plone API
Traceback (most recent call last):
File "<console>", line 3, in <module>
File "<string>", line 2, in create
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/plone.api-1.8.5-py2.7.egg/plone/api/validation.py", line 77, in wrapped
return function(*args, **kwargs)
File "<string>", line 2, in create
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/plone.api-1.8.5-py2.7.egg/plone/api/validation.py", line 149, in wrapped
return function(*args, **kwargs)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/plone.api-1.8.5-py2.7.egg/plone/api/content.py", line 88, in create
container.invokeFactory(type, content_id, **kwargs)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/PortalFolder.py", line 292, in invokeFactory
return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/TypesTool.py", line 833, in constructContent
ob = info.constructInstance(container, id, *args, **kw)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/TypesTool.py", line 311, in constructInstance
return self._constructInstance(container, id, *args, **kw)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/TypesTool.py", line 564, in _constructInstance
factory = getUtility(IFactory, self.factory)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 169, in getUtility
raise ComponentLookupError(interface, name)
ComponentLookupError: (<InterfaceClass zope.component.interfaces.IFactory>, 'Document')
3 - createContentInContainer - IDG
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/plone.dexterity-2.2.8-py2.7.egg/plone/dexterity/utils.py", line 195, in createContentInContainer
content = createContent(portal_type, **kw)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/plone.dexterity-2.2.8-py2.7.egg/plone/dexterity/utils.py", line 123, in createContent
fti = getUtility(IDexterityFTI, name=portal_type)
File "/home/clayton/desenv/portal.buildout-1.5.x/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 169, in getUtility
raise ComponentLookupError(interface, name)
ComponentLookupError: (<InterfaceClass plone.dexterity.interfaces.IDexterityFTI>, 'Document')
4 - Erro no webpack no 2.x
error hard-source-webpack-plugin@0.12.0: The engine "node" is incompatible with this module. Expected version ">=8.0.0". Got "6.6.0"
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
> brasilgovportal@2.1.1 build /home/clayton/desenv/portal.buildout-2.0/src/brasil.gov.portal/webpack
> webpack -p
sh: 1: webpack: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! brasilgovportal@2.1.1 build: `webpack -p`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the brasilgovportal@2.1.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
Por favor forneça informações adicionais que possam complementar o seu relato:
No portal exite scripts que consultam bases de conteúdos de outros sistemas de tempos em tempos para criação de páginas de conteúdos através de rotinas automatizadas.
Antes da atualização funcionava corretamente.
UPDATE
Conseguir realizar os testes no 2.x utilizando o portal.buildout sem modificações.
Ocorre os mesmos erros relatados no 1.x.
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/clayton/desenv/portal.buildout-2.0/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/PortalFolder.py", line 292, in invokeFactory
return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
File "/home/clayton/desenv/portal.buildout-2.0/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/TypesTool.py", line 833, in constructContent
ob = info.constructInstance(container, id, *args, **kw)
File "/home/clayton/desenv/portal.buildout-2.0/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/TypesTool.py", line 311, in constructInstance
return self._constructInstance(container, id, *args, **kw)
File "/home/clayton/desenv/portal.buildout-2.0/eggs/Products.CMFCore-2.2.10-py2.7.egg/Products/CMFCore/TypesTool.py", line 564, in _constructInstance
factory = getUtility(IFactory, self.factory)
File "/home/clayton/desenv/portal.buildout-2.0/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 169, in getUtility
raise ComponentLookupError(interface, name)
ComponentLookupError: (<InterfaceClass zope.component.interfaces.IFactory>, 'Document')
Achei a solução, colocando as linhas abaixo funciona com DX, é necessário configurar o registro de componente antes.
>>>from zope.component.hooks import setSite
>>>setSite(app.Plone)
>>> portal = app.Plone
>>> portal.invokeFactory('Document', 'document')
Agora o mistério é como estava funcionando antes. :)
Fonte: https://stackoverflow.com/questions/35458381/creating-a-dexterity-item-programmatically