[Erp5-dev] own getter
bartek
bartek at erp5.pl
Thu Mar 6 13:11:27 CET 2008
Łukasz Nowak wrote:
> Hello,
>
> On 2008-03-05, 13:11:44
> Tomasz Brzezina <tomasz at brzezina.pl> wrote:
>
>> I made two new properties in PropertySheet/cavempPersonProperty.py
>>
>> and after adding it in right portal_types - everything works
>> perfectly. But now I need an concatenation of those two which i need
>> in listbox -
>>
>> so I have to made a getter which returns a concatenation. The
>> question is: WHERE should I wrote the code. I think the
>> PropertySheet/cavempPersonProperty.py is the wrong place - but I have
>> no idea where is the right place. Of course I can write it in
>> anywhere patching the existing code, but this will broke updating. So
>> where should I put my code.
>
> I hit same problem some time ago - I needed to made my own accessor.
> What I done is getter in ZODB, and my property definition looks like:
>
> {
> 'id' : 'trade_name',
> 'description' : 'Trade name of resource',
> 'type' : 'string',
> 'mode' : 'w',
> 'acquisition_base_category' : ('object',),
> 'acquisition_portal_type' : Expression('python: []'),
> 'acquisition_accessor_id' : 'getTradeName',
> 'alt_accessor_id' : ('Base_getTradeName',),
> 'acquisition_mask_value' : 1,
> 'default' : '',
> },
>
Cool - I never thought about doing it like that. Why is it not on the wiki??
Bartek
> And Base_getTradeName is script in ZODB, which is doing all magic. That
> way I've got nice getTradeName method on objects, which is
> configurable using Base_getTradeName.
>
> Regards,
> Luke
>
--
"feelings affect productivity. (...) unhappy people write worse
software, and less of it."
Karl Fogel, "Producing Open Source Software"
More information about the Erp5-dev
mailing list