def zodb_open(self, req): path = req.get_selector() path = path.split('/') # XXX only the request should be required, but this looks ad-hoc.. econtext = dict(request=self.context.REQUEST) obj = boboAwareZopeTraverse(self.context, path, econtext) # check type and e.g. call object if script ... if callable(obj): try: obj = obj() except (ConflictError, RuntimeError): raise except: pass ## for OFS.Image-like objects if hasattr(obj,'_original'): obj = obj._original._data() elif hasattr(obj,'_data'): obj = obj._data elif hasattr(obj,'data'): obj = obj.data return StringIO(str(obj))
def zodb_open(self, req): path = req.get_selector() path = path.split('/') # XXX only the request should be required, but this looks ad-hoc.. econtext = dict(request=self.context.REQUEST) obj = boboAwareZopeTraverse(self.context, path, econtext) # check type and e.g. call object if script ... if callable(obj): try: obj = obj() except (ConflictError, RuntimeError): raise except: pass ## for OFS.Image-like objects if hasattr(obj, '_original'): obj = obj._original._data() elif hasattr(obj, '_data'): obj = obj._data elif hasattr(obj, 'data'): obj = obj.data return StringIO(str(obj))
def handleZODB(self, path): path = path.split("/") if boboAwareZopeTraverse is None: obj = restrictedTraverse(self.context, path, getSecurityManager()) else: # XXX only the request should be required, but this looks ad-hoc.. econtext = dict(request=self.context.REQUEST) obj = boboAwareZopeTraverse(self.context, path, econtext) # check type and e.g. call object if script ... if callable(obj): try: obj = obj() except (ConflictError, RuntimeError): raise except: pass ## for OFS.Image-like objects if hasattr(obj, "_original"): obj = obj._original._data() elif hasattr(obj, "_data"): obj = obj._data elif hasattr(obj, "data"): obj = obj.data return StringIO(str(obj))