At 14:28 2002-08-29 -0700, [EMAIL PROTECTED] said:
>I am trying to implement a proxy class (specifically for the purposes of
>multi-versioned document objects (folderish proxies that contain the object

Hi Sean,
We've been "stealing" some code from CMFCore.Skinnable to
do similar things (multi-language objects):
Skinnable gets the skins when the objects is being wrapped (e.g.
in the objects __of__ method) and overrides __getattr__ which
uses the skins or falls back to an unbound superGetAttr method
that points to the inherited __getattr__.
(The superGetAttr have pussled us because it seams like superGetAttr is None,
but everything still work as expected.)

We replace the skin with a VeryTinyDataWrapper which (of course) implements 

Would this work better that the way your doing it?
We currently implementing this so I don't know for sure that it
is faster, but it's from CMF (a key part to) so it shouldn't be to slow or?

     def setupCurrentLanguageData(self):
         #the request part is a rest from Skinnable, I don't think it can 
be removed.
         #replace this with anything that returns
         ob = self._current_language.get(lang_code, VerySmallData())
         self._v_c_language = (request, ob, {})

     def __getattr__(self, name, marker=None):
         # OK, see if we can find the language service:
         if not name.startswith('_') and not name.startswith('aq_'):
             cl = self._v_c_language
             if cl is not None:
                 request, ob, ignore = cl
                 if not ignore.has_key(name):
                     subob = getattr(ob, name, _marker)
                     if subob is not _marker:
                         # Return it in context of self, forgetting
                         # its location and acting as if it were located
                         # in self.
                         return aq_base(subob)
                         ignore[name] = 1
         if superGetAttr is None:
             raise AttributeError, name
         return superGetAttr(self, name)

     def __of__(self, parent):
         Sneakily sets up the current language then returns the wrapper
         that Acquisition.Implicit.__of__() would return.
         w_self = ImplicitAcquisitionWrapper(aq_base(self), parent)
             # This shouldn't happen, even if the requested current language
             # does not exist.
             import sys
             from zLOG import LOG, ERROR
             LOG('CMFCore', ERROR, 'Unable to setupCurrentLanguageData()',
         return w_self

Johan Carlsson

Torped Strategi och Kommunikation AB
Johan Carlsson

Birkagatan 9
SE-113 36  Stockholm

Västmannagatan 67, Stockholm, Sweden

Phone +46-(0)8-32 31 23
Fax +46-(0)8-32 31 83
Mobil +46-(0)70-558 25 24

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to