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 Acquisition.Implicit. 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. request=self.request #replace this with anything that returns lang_code=self.EasyLanguageService.getCurrentLanguage() 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) else: 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) try: w_self.setupCurrentLanguageData() except: # 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()', error=sys.exc_info()) return w_self Regards, Johan Carlsson -- Torped Strategi och Kommunikation AB Johan Carlsson [EMAIL PROTECTED] Mail: Birkagatan 9 SE-113 36 Stockholm Sweden Visit: 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 http://www.torped.se http://www.easypublisher.com _______________________________________________ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )