<tal:comment replace="nothing">
  This page is called by a XmlHttpRequest object. It requires parameters "page" and "macro":
  they are used to call the macro that will render the HTML chunk to be returned to the browser.
  It can also have a parameter "action", that refers to a method that will be triggered on
  contextObj before returning the result of the macro to the browser.
</tal:comment>
<tal:ajax define="contextObj context/getParentNode;
                  tool contextObj/getTool;
                  _ python: contextObj.translate;
                  req python: request;
                  resp req/RESPONSE;
                  page req/page;
                  macro req/macro;
                  action req/action|nothing;
                  user contextObj/getUser;
                  app tool/getApp;
                  appUrl app/absolute_url;
                  template python: contextObj.getPageTemplate(app.ui, page);
                  lang tool/getUserLanguage;
                  dir python: tool.getLanguageDirection(lang);
                  dleft python: (dir == 'ltr') and 'left' or 'right';
                  dright python: (dir == 'ltr') and 'right' or 'left';
                  x python: resp.setHeader('Content-Type','text/html;;charset=utf-8');
                  x python: resp.setHeader('Expires', 'Mon, 11 Dec 1975 12:05:05 GMT');
                  x python: resp.setHeader('Content-Language', lang);
                  x python: resp.setHeader('CacheControl', 'no-cache')">
  <tal:comment replace="nothing">Keys "Expires" and "CacheControl" are used for preventing IE to cache
    this page. Indeed, this page is retrieved through an asynchronous XMLHttpRequest by the browser, and
    IE caches this by default.</tal:comment>
  <tal:executeAction condition="action">
    <tal:do define="x python: contextObj.getMethod('on'+action)()" omit-tag=""/>
  </tal:executeAction>
  <metal:callMacro use-macro="python: template.macros.get(macro)"/>
</tal:ajax>
