def index_html(self): """ Acquire if not present. """ request = getattr(self, 'REQUEST', None) if request is not None and 'REQUEST_METHOD' in request: if request.maybe_webdav_client: method = request['REQUEST_METHOD'] if method in ('PUT', ): # Very likely a WebDAV client trying to create something return ReplaceableWrapper(NullResource(self, 'index_html')) elif method in ('GET', 'HEAD', 'POST'): # Do nothing, let it go and acquire. pass else: raise AttributeError('index_html') # Acquire from skin. _target = self.__getattr__('index_html') return ReplaceableWrapper(aq_base(_target).__of__(self))
def testIndexHtmlReplaceableWrapper(self): self.portal.document.index_html = ReplaceableWrapper(None) layout = self.portal.document.getLayout() self.assertEqual(self.putils.browserDefault(self.portal.document), (self.portal.document, [layout]))