It is very easy to use FCKeditor in your Python web pages. To start the integration follow the instructions below.
Contents
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.