[Plone-IT] Settare un campo da script

Yuri yurj a alfa.it
Mer 22 Giu 2011 08:46:01 UTC


A me AJ aveva detto:

"

Fields introduced through schemaextender do not have accessor mutator
methods. You have to use

some_obj.getField(fieldname).set(some_obj, value)
value = some_obj.getField(fieldname).get(some_obj)

"

Anch'io avevo provato la strada indicata da te e Fabrizio, ma non 
funzionava. Avevo anche seguito questa strada:

http://plone.293351.n2.nabble.com/Accessors-for-SchemaExtender-fields-in-BrowserViews-td4610706.html

> On 2010-02-22, at 0740, David Siedband wrote:
>
> > How can I access these SchemaExtender-added fields in my BrowserView?
>
> context.Schema()['fair_use'].getAccessor()() should work.  There are
> plenty of other, equivalent spellings, like calling .get(context) on
> the field object, too.
>
> SchemaExtender fields don't auto-generate the accessor/mutator methods
> on objects they're applied to, so you need to use the archetypes API.

Sandro ci dirà com'è andata :)


Il 22/06/2011 10:35, SauZheR ha scritto:
>> mi sa che con schemaextender non va, non crea i mutator accessor di default.
>> È cambiato qualcosa nel frattempo?
>>      
>   class MyBooleanField(ExtensionField, BooleanField):
>           """A trivial field."""
>
> schemaextender can not use the standard Archetypes fields directly
> since those rely on the class generation logic generating accessors
> and mutator methods. By using the ExtensionField mix-in class we can
> still use them. Make sure the ExtensionField mix-in comes first, so it
> properly overwrites the standard methods.
>
>
>
> RTFM ;)
> http://pypi.python.org/pypi/archetypes.schemaextender
>
>    



Maggiori informazioni sulla lista Plone-IT