[Erp5-dev] own getter

bartek bartek at erp5.pl
Sat Mar 8 11:26:59 CET 2008


Tomasz Brzezina wrote:
> bartek pisze:
>> 1. Create a property the way Luke told you to, with alt_accessor_id 
>> defining the name of the script (like Product_getCustomerNumber)
> Now it looks:
>  class cavempPersonReference:
>     """
>         Szczegolowe informacje o kliencie
>     """
> 
>     _properties = (
>         {'id'         :   'family_number',
>         'description' : '',
>         'type'        : 'string',
>         'mode'        : 'w'},
>     { 'id'          : 'person_in_family_number',
>     'description' : '',
>     'type'        : 'string',
>     'mode'        : 'w' },
>         { 'id'          : 'customer_number',
>     'description' : '',
>     'type'        : 'string',
>     'mode'        : 'w',
>         'acquisition_base_category' : ('object',),
>         'acquisition_portal_type' : Expression('python: []'),
>         'acquisition_accessor_id' : 'getCustomerNumber',
>         'alt_accessor_id' : ('Person_getCustomerNumber',),
>         'acquisition_mask_value' : 1,
>         'default'     : '',}
>     )
>> Reload the property sheet, make sure it is attached to the portal 
>> type. Once you do this, every object of this portal type (e.g.Product) 
>> already has an auto-generated accessor "getCustomerNumber".
> Fails -
> 
> Error Type: NameError
> Error Value: name 'Expression' is not defined.

Fish:

from Products.CMFCore.Expression import Expression

Fishing rod:

cd Products/ERP5/PropertySheet
grep Expression *

> 
>> 2. Create a script Product_getCustomerNumber in "custom" skin or in 
>> any other skin which is in the skin queue (read CMF documentation for 
>> details). Which one you choose doesn't really matter from technical 
>> point of view, it is a matter of convention - e.g. if this relates to 
>> a Product portal type you should create a skin like "tomek_pdm", being 
>> an overay to erp5_pdm, and put it there.
> Ok. For now it would be in Custom ;D  The cleaning and dividing will be 
> later.
> 
> Now the script is very stupid:
> ------------8<-----------8<------------8<----------
> return "000134"
> ------------8<-----------8<------------8<----------
> but I wonder how to access getFamilyNumber and getPersonInFamilyNumber
> 
> like this?
> ------------8<-----------8<------------8<----------
> return context.getFamilyNumber+context.getPersonInFamilyNumber
> ------------8<-----------8<------------8<----------
>

Yes (did you try?).

Bartek


> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Erp5-dev mailing list
> Erp5-dev at erp5.org
> http://mail.nexedi.com/mailman/listinfo/erp5-dev


-- 
"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