nuxeo-localizer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nuxeo-localizer] Re: __getattr__ in LocalPropertyManager


From: Juan David Ibáñez Palomar
Subject: [Nuxeo-localizer] Re: __getattr__ in LocalPropertyManager
Date: Tue, 26 Feb 2002 11:14:49 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020214

Hi Dyon,

I cc this message to the mailing list, it could interest somebody else
and I want it to be archived.


Dyon Balding wrote:

Hi,

I am using a number of ideas from the Localizer product, and
mainly the LocalPropertyManager class to retrofit i18n into
a large ZClass based product.

I was a little intrigued by the use of __getattr__ in
LocalPropertyManager.  From what I can tell, LocalPropertyManager
is used as a mix-in class for classes that are already
Persistent.  However, I was under the impression that it
was bad form to overload __getattr__ and __setattr__ in
any Persistent class.  Is the way it's implemented safe?
Or is it just working?

I'd like to use the same idea, but I don't want to introduce any subtle errors.

thanks
-d


If my memory doesn't fails (and it fails often)...

There was a problem with persistence and these methods, but it was
a while ago. It don't exists now, I don't remember in which version
the problem was solved.

Currently, there's a performance problem with acquisition. I remember
a while ago debugging TransparentFolders, it was impressive how many
times the "__getattr__" was called for a request.


LocalPropertyManager uses computed attributes (with ExtensionClass)
for the multilingual properties. For example, "title" and "body" are
multingual properties in the LocalContent meta type.

You can type "ob.title" and it will return the title of the object in the
right language. To get a multilingual property in a specified language,
you can use the API, "getLocalProperty('title', 'es')".


But, what if you want to catalog your object? You can't use the computed
attribute because then the object only will be indexed by one language. You
can't use the "getLocalProperty" method because it's a method that requires
at least one argument, and the catalog only works with methods that don't
require arguments.

This is the reason for the "__getattr__" method, it's used to define attributes
like "title_en", "title_es", etc.. They're useful for cataloging.


So, this idea is safe to use. However, I don't know which is its performance
impact.

Also, the mixin class "LocalPropertyManager" can be used as a base class
for ZClasses, perhaps it will save you some time.

Finally, I've to document all this, there're lot of things that can be done
with Localizer from the file system and that are undocumented.


Regards,


--
J. David Ib??ez, Nuxeo.com
Debian user (http://www.debian.org)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]