title: 404 error handling with mako template
body: <p>Trying to display template rendered by mako on 404 errors, but it still displays standart error page with cherrypy footer and additional message: |In addition, the custom error page failed: TypeError: render_body() takes exactly 1 argument (3 given)"
  The code:</p>
  
  <pre><code>def error_page_404(status, message, traceback, version):
      tmpl = tpl.get_template("404.mako")
      return tmpl.render(status, message)
  cherrypy.config.update({'error_page.404': error_page_404})
  </code></pre>
  
  <p>Need help! How to display completely custom error pages with my layout(mako template)?</p>
  
  <p>Full code:</p>
  
  <pre><code>import sys
  sys.stdout = sys.stderr
  import os, atexit
  import threading
  import cherrypy
  from mako.template import Template
  from mako.lookup import TemplateLookup
  
  cherrypy.config.update({'environment': 'embedded'})
  if cherrypy.engine.state == 0:
      cherrypy.engine.start(blocking=False)
      atexit.register(cherrypy.engine.stop)
  
  localDir = os.path.dirname(__file__)
  absDir = os.path.join(os.getcwd(), localDir)
  path = os.path.join(absDir,'files')
  templ_path = os.path.join(absDir,'html')
  
  tpl = TemplateLookup(directories=[templ_path], input_encoding='utf-8', output_encoding='utf-8',encoding_errors='replace')
  
  def error_page_404(status, message, traceback, version):
      tmpl = tpl.get_template("404.mako")
      return tmpl.render(status, message)
  cherrypy.config.update({'error_page.404': error_page_404})
  
  class Root:
      def index(self):
      tmpl = tpl.get_template("index.mako")       
      return tmpl.render(text = 'Some text',url = cherrypy.url())
  index.exposed = True    
  
  _application = cherrypy.Application(Root(), None)
  
  import posixpath
  
  def application(environ, start_response):
      environ['SCRIPT_NAME'] = posixpath.dirname(environ['SCRIPT_NAME'])
      if environ['SCRIPT_NAME'] == '/':
          environ['SCRIPT_NAME'] = ''
          return _application(environ, start_response)
  </code></pre>