[Erp5-dev] own getter

Łukasz Nowak lukasz.nowak at ventis.com.pl
Thu Mar 6 12:24:15 CET 2008


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'     : '',
    },

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

-- 
Łukasz Nowak R&D Ventis http://www.ventis.com.pl/
tel: +48 32 768 16 85 fax: +48 32 392 10 61
``Use the Source, Luke...'' I am only craftsman.



More information about the Erp5-dev mailing list