domanda su getField

3 messages Options
Embed this post
Permalink
Yuri-11

domanda su getField

Reply Threaded More More options
Print post
Permalink
        campi = ['title', 'Rapporto_giornaliero',
'Operatori_cooperativa', 'Problemi_organizzativi',
'Problemi_biblioteca', 'Problemi_allo_stabile', 'Note',
'Utenti_presenti', 'Utenti_apertura_straordinaria',
'Utenti_presenti_1920', 'Utenti_totale', 'Numero_prestiti',
'Numero_restituzioni', 'Numero_rinnovi_straordinaria',
'Numero_prenotazioni']

        for c in campi:
         row.append(self.getField(c).get(self))

perchè non funziona? :)

 Mi torna l'errore:

    * Module Products.Archetypes.Field, line 1989, in get

TypeError: eval() arg 1 must be a string or code object

 se al posto di c metto la stringa con il nome del campo, funziona...


_______________________________________________
Plone-IT mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/plone-it
http://www.nabble.com/Plone---Italy-f21728.html
Yuri-11

Re: domanda su getField

Reply Threaded More More options
Print post
Permalink
Yuri ha scritto:

>        campi = ['title', 'Rapporto_giornaliero',
> 'Operatori_cooperativa', 'Problemi_organizzativi',
> 'Problemi_biblioteca', 'Problemi_allo_stabile', 'Note',
> 'Utenti_presenti', 'Utenti_apertura_straordinaria',
> 'Utenti_presenti_1920', 'Utenti_totale', 'Numero_prestiti',
> 'Numero_restituzioni', 'Numero_rinnovi_straordinaria',
> 'Numero_prenotazioni']
>
>        for c in campi:
>         row.append(self.getField(c).get(self))
>
> perchè non funziona? :)
>
> Mi torna l'errore:
>
>    * Module Products.Archetypes.Field, line 1989, in get
>
> TypeError: eval() arg 1 must be a string or code object
>
> se al posto di c metto la stringa con il nome del campo, funziona...
L'errore avviene sui computedField, evidentemente perchè .get() non è il
loro accessor :)


_______________________________________________
Plone-IT mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/plone-it
http://www.nabble.com/Plone---Italy-f21728.html
Riccardo Lemmi

Re: domanda su getField

Reply Threaded More More options
Print post
Permalink
On Thursday 25 June 2009, Yuri wrote:

> Yuri ha scritto:
> >        campi = ['title', 'Rapporto_giornaliero',
> > 'Operatori_cooperativa', 'Problemi_organizzativi',
> > 'Problemi_biblioteca', 'Problemi_allo_stabile', 'Note',
> > 'Utenti_presenti', 'Utenti_apertura_straordinaria',
> > 'Utenti_presenti_1920', 'Utenti_totale', 'Numero_prestiti',
> > 'Numero_restituzioni', 'Numero_rinnovi_straordinaria',
> > 'Numero_prenotazioni']
> >
> >        for c in campi:
> >         row.append(self.getField(c).get(self))
> >
> > perchè non funziona? :)
> >
> > Mi torna l'errore:
> >
> >    * Module Products.Archetypes.Field, line 1989, in get
> >
> > TypeError: eval() arg 1 must be a string or code object
> >
> > se al posto di c metto la stringa con il nome del campo, funziona...
>
> L'errore avviene sui computedField, evidentemente perchè .get() non è il
> loro accessor :)
Il codice del get di ComputedField è:

    def get(self, instance, **kwargs):
        """Return the computed value."""
        return eval(self.expression, {'context': instance, 'here' : instance})

dall'errore lanciato sembra semplicemente che 'expression' non sia codice
valido ("string or code object").
--
Riccardo Lemmi                           Email:   [hidden email]
Reflab S.r.l. - Plone Design, Development and Consulting
Phone: +39 349 4620820                         http://www.reflab.it


_______________________________________________
Plone-IT mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/plone-it
http://www.nabble.com/Plone---Italy-f21728.html

signature.asc (196 bytes) Download Attachment