[Erp5-dev] own getter

Tomasz Brzezina tomasz at brzezina.pl
Sat Mar 8 11:27:16 CET 2008


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.

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

-- 
T.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.tiolive.com/pipermail/erp5-dev/attachments/20080308/38549b5b/attachment.bin>


More information about the Erp5-dev mailing list