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.

 
Line 5: Line 5:
 
=== Step 1 ===
 
=== Step 1 ===
  
Ensure that the fckeditor.py is included in your classpath
+
Ensure that the fckeditor.py is included in your classpath. Then, at first, import FCKeditor:<br>
 
<pre>import fckeditor
 
<pre>import fckeditor
</pre>  
+
</pre>
 +
 
 
=== Step 2 ===
 
=== Step 2 ===
  

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.