source: sandbox/filemanager/tp/fckeditor/editor/filemanager/connectors/py/wsgi.py @ 1575

Revision 1575, 1.6 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Implentação, melhorias do modulo gerenciador de arquivos

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2
3"""
4FCKeditor - The text editor for Internet - http://www.fckeditor.net
5Copyright (C) 2003-2009 Frederico Caldeira Knabben
6
7== BEGIN LICENSE ==
8
9Licensed under the terms of any of the following licenses at your
10choice:
11
12 - GNU General Public License Version 2 or later (the "GPL")
13   http://www.gnu.org/licenses/gpl.html
14
15 - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
16   http://www.gnu.org/licenses/lgpl.html
17
18 - Mozilla Public License Version 1.1 or later (the "MPL")
19   http://www.mozilla.org/MPL/MPL-1.1.html
20
21== END LICENSE ==
22
23Connector/QuickUpload for Python (WSGI wrapper).
24
25See config.py for configuration settings
26
27"""
28
29from connector import FCKeditorConnector
30from upload import FCKeditorQuickUpload
31
32import cgitb
33from cStringIO import StringIO
34
35# Running from WSGI capable server (recomended)
36def App(environ, start_response):
37        "WSGI entry point. Run the connector"
38        if environ['SCRIPT_NAME'].endswith("connector.py"):
39                conn = FCKeditorConnector(environ)
40        elif environ['SCRIPT_NAME'].endswith("upload.py"):
41                conn = FCKeditorQuickUpload(environ)
42        else:
43                start_response ("200 Ok", [('Content-Type','text/html')])
44                yield "Unknown page requested: "
45                yield environ['SCRIPT_NAME']
46                return
47        try:
48                # run the connector
49                data = conn.doResponse()
50                # Start WSGI response:
51                start_response ("200 Ok", conn.headers)
52                # Send response text
53                yield data
54        except:
55                start_response("500 Internal Server Error",[("Content-type","text/html")])
56                file = StringIO()
57                cgitb.Hook(file = file).handle()
58                yield file.getvalue()
Note: See TracBrowser for help on using the repository browser.