[Zope] How to do...

Jonathan dev101 at magma.ca
Wed Oct 18 10:29:06 EDT 2006


----- Original Message ----- 
From: "Garito" <garito at sistes.net>
To: "Lista Zope Internacional" <zope at zope.org>
Sent: Wednesday, October 18, 2006 10:15 AM
Subject: [Zope] How to do...


> Hi all!
>
> How can I control the way an attribute of a product is readed? 
> __getattr__? __getattribute__?
>
> I try the __getattribute__ way but it modifies the property pages
>
> Example:
>
> I create an object instance of the product and like:
>
> Property1 = 'Some text'
> Property2 = 2006-10-18
>
> I would like to call Property2 like
>
> object.Property2 and retrieve the data with the current locale
>
> For spanish locale I would like to retrieve 18-10-2006
>
> But if I read the property pages of this object I would like to conserve 
> the given data
>
> Is this possible?

Reading/displaying stored data should not change the stored data!  You 
should determine what internal data storage format you want and keep it 
consistent.  When you retrieve data for presentation/display you can 
reformat the data prior to display (eg. for localization), but you should 
not overwrite the stored data with the new format (this will cause you 
serious difficulties as your data 'reading' routines will never know what 
format the data is stored in - unless you also store some formatting 
information, but in most cases this is a bad idea!)

Jonathan 




More information about the Zope mailing list