Project

General

Profile

1
#!/usr/bin/env python
2

    
3
"""
4
FCKeditor - The text editor for Internet - http://www.fckeditor.net
5
Copyright (C) 2003-2009 Frederico Caldeira Knabben
6

    
7
== BEGIN LICENSE ==
8

    
9
Licensed under the terms of any of the following licenses at your
10
choice:
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

    
23
Connector/QuickUpload for Python (WSGI wrapper).
24

    
25
See config.py for configuration settings
26

    
27
"""
28

    
29
from connector import FCKeditorConnector
30
from upload import FCKeditorQuickUpload
31

    
32
import cgitb
33
from cStringIO import StringIO
34

    
35
# Running from WSGI capable server (recomended)
36
def 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()
(9-9/10)