[Erp5-users] Object side security settings - Dynamic calculation
bartek
bartek at erp5.pl
Tue Oct 9 14:38:07 CEST 2007
Sebastian Bijak wrote:
> In Handbook in section Back to the (almost) real example there is an exemplary
> script for dynamic calculation. I'm asking about 5th line of this script:
>
> city = customer.getDefaultAddressCity()
>
> In this line there is DefaultAddress and City. I've found default_address as
> storage_id in PropertySheet/Person.py for property address and as
> acquisition_object_id in category region. City is in PropertySheet/Person.py as
> acquired_property_id for property address. Type of property address is "content".
> "How to store a property as a subobject" refers to Programmable acquisition
> sectio 'content' data type. So i guess that default_address is an object and
> properties such as region, city, zip_code and street_address are stored in it.
> So i'm asking if i have to store properties this way to get their values in
> script ?
>
No, you can store them directly and use standard accessors. Actually, this:
customer.getDefaultAddressCity()
is the same as:
customer.default_address.getCity()
(or, to be very precise):
hasattr(customer, 'default_address') and
customer.default_address.getCity() or ''
And
customer.setDefaultAddressCity('xxx')
is roughly equivalent to:
if not hasattr(customer, 'default_address'):
customer.newContent(id='default_address', portal_type='Address')
customer.default_address.setCity('xxx')
You can get many properties directly from a Person, like:
customer.getFirstName()
Bartek
> regards
> Sebastian
>
> _______________________________________________
> Erp5-users mailing list
> Erp5-users at erp5.org
> http://mail.nexedi.com/mailman/listinfo/erp5-users
>
--
"feelings affect productivity. (...) unhappy people write worse
software, and less of it."
Karl Fogel, "Producing Open Source Software"
More information about the Erp5-users
mailing list