[plonegov-br] [Erro com código simples utilizando External Methods]
Alexandre Chagas
alexandre.acs em gmail.com
Quinta Março 7 14:53:06 BRT 2019
Olá Pessoal,
Estou fazendo uma migração de registros por meio de um arquivo CSV, e está
acontecendo algo que não tem lógica.
O mesmo código Python com “External Methods” funciona numa instalação e na
outra aparece erro de atributo. Por favor, se alguém puder apontar onde
estou errando!
Meu código é este: (não reparem o código super tosco, mas foi aonde
consegui chegar sem saber python)
*import csv, sys, string, re*
*from DateTime import DateTime*
*from zope.component import queryUtility, createObject*
*from plone.i18n.normalizer.interfaces import IIDNormalizer*
*def import_data(self):*
* reader = csv.reader(open('/tmp/noticias5000-v2-completo.csv'),
delimiter=';', quotechar='"', doublequote=Fa$*
* fim = "fim."*
* quant = 0*
* for row in reader:*
* if row[0] != 'id':*
* id = self.generateUniqueId('Document')*
* stat=row*
* self.invokeFactory('Document', id)*
* nn = getattr(self, id)*
* x_titulo = row[1]*
* print x_titulo*
* data = row[3]*
* print data*
* dia = str(int(data[:2]))*
* if int(dia) < 10:*
* dia = "0"+dia*
* mes = str(int(data[3:5]))*
* if int(mes) < 10:*
* mes = "0"+mes*
* ano = str(int(data[6:10]))*
* datafinal = ano+"/"+mes+"/"+dia*
* print datafinal*
* autor = row[5]*
* if autor == "":*
* autor = "ASCOM/ANA"*
* nn.setCreators(autor)*
* nn.setEffectiveDate(DateTime(datafinal))*
* nn.setModificationDate(DateTime(row[4]))*
* nn.setCreationDate(DateTime(row[3]))*
* nn.setTitle(row[1])*
* nn.setDescription(row[2])*
* nn.setText(row[6])*
* nn.portal_workflow.doActionFor(nn,"publish", comment="")*
* nn.reindexObject()*
* quant = quant + 1*
* print quant*
* return fim*
*Na versão Plone, sem o IDG consigo efetuar a migração de dados.Sem erro
algum, *
*Versão*
*• Plone 4.3.18 (4320)*
*• CMF 2.2.10*
*• Zope 2.13.28*
*• Python 2.7.12 (default, Feb 7 2019, 11:36:40) [GCC 4.7.2]*
*• PIL 3.3.1 (Pillow)*
*E nessa versão Plone com o IDG, aparece erro de parâmetro:*
*Versão*
*. Portal Padrão 1.1.5.1*
*. Plone 4.3.9 (4313)*
*. CMF 2.2.9*
*. Zope 2.13.24*
*. Python 2.7.12 (default, Jul 27 2017, 09:49:26) [GCC 4.7.2]*
*. PIL 3.3.1 (Pillow)*
MSG DE ERRO:
2019-03-07 14:21:48 ERROR Zope.SiteErrorLog 1551979308.610.397350171831
http://10.1.10.26:8082/portal/ANA/noticias-antigas/migrarnoticias
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 Products.ExternalMethod.ExternalMethod, line 237, in __call__
- __traceback_info__: ((<Folder at /portal/ANA/noticias-antigas>,), {},
None)
Module
/opt/Plone-4.3.11-portal-ana/zeocluster/parts/client1/Extensions/importcsv3.py,
line 43, in import_data
AttributeError: setCreationDate
///
O que pode estar acontecendo? Agradeço muito qualquer ajuda.
--
*Alexandre Chagas*
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.interlegis.gov.br/pipermail/plonegov-br/attachments/20190307/06a39bcf/attachment.html>
Mais detalhes sobre a lista de discussão PloneGov-BR