#!/usr/bin/env python
#!C:/Python27/python.exe
# -*- coding: UTF-8 -*-
#    arena v1.0
#    Copyright (C) 2012-2013 by Michael Malicoat.
#
#    arena is free software: you can redistribute it and/or modify it
#    under the terms of the GNU General Public License as published by the
#    Free Software Foundation; either version 3 of the License or, at your
#    option, any later version.
#
#    arena is distributed in the hope that it will be useful, but
#    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABLITY
#    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
#    License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with arena.  If not, see <http://www.gnu.org/licenses/>.

## \file 
#  This file defines the main entry point for arena: where the client request,
#  the content, and its display all come together.

## \mainpage Arena
#  Arena is a content management system, written in Python, that is designed
#  to be simple, elegant, and flexible.  To that end, it provides a thin layer
#  of "glue" that marries the content of the site to the presentation of that
#  content.  This allows site content and site design to be updated 
#  independently of each other.  
#
#  Arena places only a single constraint on what constitutes "content": it must
#  be contained within an iterable Python object, such as a `dict`, a `list`, 
#  or any other class that supports the Python iteration protocol.  In like
#  fashion, arena places only two constraints on what constitutes
#  "presentation": the object or function responsible for presentation must
#  accept an iterable Python object that contains the content to display, and
#  it must return a string.  Simple though these rules may be, they nevertheless
#  ensure a system that is dynamic and flexible enough to handle nearly any
#  type of content, from any source, that is displayed in nearly any way.
#
#  For more information on how arena works, see 
#  http://www.circusmachina.com/arena/code/arena.

## \page License License
#  arena is distributed under the terms of the GNU General Public License, 
#  version 3.  You can find the terms of that license in the `COPYING` file
#  which is included with arena, or at http://www.gnu.org/licenses/.
#
#  arena is free software: you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; either version 3 of the License or, at your
#  option, any later version.
#
#  arena is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABLITY
#  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
#  License for more details.
#
#  You should have received a copy of the GNU General Public License along
#  with arena.  If not, see <http://www.gnu.org/licenses/>.

from Plugins.Application.Arena.Viewpoints import AViewpoint
import cgi, sys

def exception(etype, evalue, trace):
    import traceback
    lines = traceback.format_exception(etype, evalue, trace)
    output = "<html>\n<body>\n<pre> " + "\n".join(lines)
    output +=  "</pre>\n</body>\n</html>"
    print "Content-type: text/html"
    print "Content-length: " + str(len(output))
    print 
    print output

def main():
    #sys.excepthook = exception
    Mediator = AViewpoint()
    result = Mediator.run()
    del Mediator

    return result

if __name__ == '__main__':
    main()
