(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 === | ||
− | + | 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 | + | 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>: |
− | <pre> | + | <pre>try: |
− | try: | + | |
− | |||
sBasePath = os.environ.get("SCRIPT_NAME") | 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: | except Exception, 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 """ | + | 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 | # This is the real work | ||
try: | 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: | except Exception, e: | ||
− | + | print e | |
print """ | print """ | ||
− | + | <br> | |
− | + | <input type="submit" value="Submit"> | |
− | + | </form> | |
""" | """ | ||
# For testing your environments | # For testing your environments | ||
− | print " | + | print "<hr>" |
for key in os.environ.keys(): | for key in os.environ.keys(): | ||
− | + | print "%s: %s<br>" % (key, os.environ.get(key, "")) | |
− | print " | + | print "<hr>" |
# Document footer | # Document footer | ||
print """ | print """ | ||
− | + | </body> | |
− | + | </html> | |
""" | """ | ||
− | </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.
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.