Python"

This website contains links to software which is either no longer maintained or will be supported only until the end of 2019 (CKFinder 2). For the latest documentation about current CKSource projects, including software like CKEditor 4/CKEditor 5, CKFinder 3, Cloud Services, Letters, Accessibility Checker, please visit the new documentation website.

If you look for an information about very old versions of CKEditor, FCKeditor and CKFinder check also the CKEditor forum, which was closed in 2015. If not, please head to StackOverflow for support.

(New page: It is very easy to use FCKeditor in your Python web pages. To start the integration follow the instructions below. == Integration step by step == === Step 1 === The first thing to do is...)
 
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
 
=== Step 1 ===
 
=== Step 1 ===
  
The first thing to do is to import '''fckeditor''' in the top of your page as in the example below:  
+
Ensure that the fckeditor.py is included in your classpath. Then, at first, import FCKeditor:<br>
<pre>
+
<pre>import fckeditor
import fckeditor
 
 
</pre>
 
</pre>
  
 
=== Step 2 ===
 
=== Step 2 ===
  
Now the FCKeditor is available and ready to use. So, just insert the following code in your page to create an instance of the editor inside a <FORM>:
+
Now the FCKeditor is available and ready to use. So, just insert the following code in your page to create an instance of the editor inside a &lt;FORM&gt;:
<pre>
+
<pre>try:
try:
+
 
 
 
sBasePath = os.environ.get("SCRIPT_NAME")
 
sBasePath = os.environ.get("SCRIPT_NAME")
sBasePath = sBasePath["/fckeditor/"]
+
sBasePath = sBasePath["/fckeditor/"]
  
oFCKeditor = fckeditor.FCKeditor('FCKeditor1')
+
oFCKeditor = fckeditor.FCKeditor('FCKeditor1')
oFCKeditor.BasePath = sBasePath
+
oFCKeditor.BasePath = sBasePath
oFCKeditor.Value = """<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>"""
+
oFCKeditor.Value = """&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://www.fckeditor.net/"&gt;FCKeditor&lt;/a&gt;.&lt;/p&gt;"""
print oFCKeditor.Create()
+
print oFCKeditor.Create()
 
except Exception, e:
 
except Exception, e:
print e
+
print e
 
print """  
 
print """  
</pre>
+
</pre>  
 
 
 
=== Step 3 ===
 
=== Step 3 ===
  
The editor is now ready to be used. Just open the page in your browser to see it at work.  
+
The editor is now ready to be used. Just open the page in your browser to see it at work.
  
 
=== Complete Sample ===
 
=== Complete Sample ===
<pre>
+
<pre>import cgi
import cgi
 
 
import os
 
import os
  
Line 45: Line 41:
  
 
# Document header
 
# Document header
print """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
print """&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
<html>
+
&lt;html&gt;
<head>
+
&lt;head&gt;
<title>FCKeditor - Sample</title>
+
&lt;title&gt;FCKeditor - Sample&lt;/title&gt;
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
<meta name="robots" content="noindex, nofollow">
+
&lt;meta name="robots" content="noindex, nofollow"&gt;
</head>
+
&lt;/head&gt;
<body>
+
&lt;body&gt;
<form action="sampleposteddata.py" method="post" target="_blank">
+
&lt;form action="sampleposteddata.py" method="post" target="_blank"&gt;
 
"""
 
"""
  
 
# This is the real work
 
# This is the real work
 
try:
 
try:
sBasePath = os.environ.get("SCRIPT_NAME")
+
sBasePath = os.environ.get("SCRIPT_NAME")
sBasePath = sBasePath[0:sBasePath.find("_samples")]
+
sBasePath = sBasePath[0:sBasePath.find("_samples")]
  
oFCKeditor = fckeditor.FCKeditor('FCKeditor1')
+
oFCKeditor = fckeditor.FCKeditor('FCKeditor1')
oFCKeditor.BasePath = sBasePath
+
oFCKeditor.BasePath = sBasePath
oFCKeditor.Value = """<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>"""
+
oFCKeditor.Value = """&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://www.fckeditor.net/"&gt;FCKeditor&lt;/a&gt;.&lt;/p&gt;"""
print oFCKeditor.Create()
+
print oFCKeditor.Create()
 
except Exception, e:
 
except Exception, e:
print e
+
print e
 
print """
 
print """
<br>
+
&lt;br&gt;
<input type="submit" value="Submit">
+
&lt;input type="submit" value="Submit"&gt;
</form>
+
&lt;/form&gt;
 
"""
 
"""
  
 
# For testing your environments
 
# For testing your environments
print "<hr>"
+
print "&lt;hr&gt;"
 
for key in os.environ.keys():
 
for key in os.environ.keys():
print "%s: %s<br>" % (key, os.environ.get(key, ""))
+
print "%s:&nbsp;%s&lt;br&gt;"&nbsp;% (key, os.environ.get(key, ""))
print "<hr>"
+
print "&lt;hr&gt;"
  
 
# Document footer
 
# Document footer
 
print """
 
print """
</body>
+
&lt;/body&gt;
</html>
+
&lt;/html&gt;
 
"""
 
"""
</pre>
+
</pre>  
 
"FCKeditor1" is the name used to post the editor data on forms.
 
"FCKeditor1" is the name used to post the editor data on forms.
  

Latest revision as of 13:43, 22 January 2008

It is very easy to use FCKeditor in your Python web pages. To start the integration follow the instructions below.

Integration step by step

Step 1

Ensure that the fckeditor.py is included in your classpath. Then, at first, import FCKeditor:

import fckeditor

Step 2

Now the FCKeditor is available and ready to use. So, just insert the following code in your page to create an instance of the editor inside a <FORM>:

try:

sBasePath = os.environ.get("SCRIPT_NAME")
sBasePath = sBasePath["/fckeditor/"]

oFCKeditor = fckeditor.FCKeditor('FCKeditor1')
oFCKeditor.BasePath = sBasePath
oFCKeditor.Value = """<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>"""
print oFCKeditor.Create()
except Exception, e:
print e
print """ 

Step 3

The editor is now ready to be used. Just open the page in your browser to see it at work.

Complete Sample

import cgi
import os

# Ensure that the fckeditor.py is included in your classpath
import fckeditor

# Tell the browser to render html
print "Content-Type: text/html"
print ""

# Document header
print """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>FCKeditor - Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
</head>
<body>
<form action="sampleposteddata.py" method="post" target="_blank">
"""

# This is the real work
try:
sBasePath = os.environ.get("SCRIPT_NAME")
sBasePath = sBasePath[0:sBasePath.find("_samples")]

oFCKeditor = fckeditor.FCKeditor('FCKeditor1')
oFCKeditor.BasePath = sBasePath
oFCKeditor.Value = """<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>"""
print oFCKeditor.Create()
except Exception, e:
print e
print """
<br>
<input type="submit" value="Submit">
</form>
"""

# For testing your environments
print "<hr>"
for key in os.environ.keys():
print "%s: %s<br>" % (key, os.environ.get(key, ""))
print "<hr>"

# Document footer
print """
</body>
</html>
"""

"FCKeditor1" is the name used to post the editor data on forms.

Additional information

  • You can find some samples on how to use the editor in the "_samples/py" directory.
This page was last edited on 22 January 2008, at 13:43.