[Plone-IT] Stranezza archetype con aggiunta nuovo campo

Michele Mordenti michele.mordenti a gmail.com
Lun 11 Feb 2013 14:49:05 UTC


Ho un comportamento inatteso, e non riesco a capire dove sia l'errore.
In breve, quando aggiungo un campo nuovo, che devo fare con i vecchi
oggetti che ne sono privi?

Ho un tracker Products.Poi 1.X personalizzato con +o- 5.200 ticket.
Mi serve un campo in più nello schema archetype.
Lo aggiungo: StringField(name='company_name',.....)

Il valore è letto dall'attributo utente "company" mappato su LDAP/AD.
Se esiste mi propone quello, altrimenti lo setta l'utente.

Nella vista ho una banale chiamata al nome del campo:
<td tal:content="here/getCompany_name" />

Installo la nuova versione del prodotto.
Creo nuovi ticket e tutto ok, vedo il campo con l'attributo giusto e
visualizzando i vecchi e vedo correttamente il campo vuoto.
Faccio ripartire l'istanza ma questa volta nei vecchi ticket il campo è già
popolato con un valore mai impostato. Come mai?

Un aggiornameto dello schema:
http://localhost:8080/ploneID/archetype_tool/manage_updateSchemaForm
sembra aver rimesso le cose a posto.
E' normale?

Questo warning mi spaventa un poco:
This is an experimental mechanism for updating your existing objects when
you update an Archetypes class's schema. It rebuilds all your objects using
a simple migration mechanism: it gathers all your object's values using the
existing field accessors, updates the schema, re-initializes the object,
and finally resets the values using the new field mutators. It should be
fairly smart about detecting schema changes in your objects. Use at your
own risk.

Grazie.

-- 
Michele Mordenti
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.plone.org/pipermail/plone-plone-it/attachments/20130211/162c868d/attachment.html>


Maggiori informazioni sulla lista Plone-IT