Chinaunix首页 | 论坛 | 博客
  • 博客访问: 205271
  • 博文数量: 48
  • 博客积分: 1935
  • 博客等级: 上尉
  • 技术积分: 491
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-29 00:59
文章分类

全部博文(48)

文章存档

2011年(1)

2010年(47)

我的朋友

分类: Python/Ruby

2010-11-04 04:00:24

Use FCKeditor in Python web pages.
2008-10-23 13:13

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

:

try:

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

oFCKeditor = fckeditor.FCKeditor('FCKeditor1')
oFCKeditor.BasePath = sBasePath
oFCKeditor.Value = """

This is some sample text. You are using FCKeditor.

"""
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 """


FCKeditor - Sample





"""

# 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 = """

This is some sample text. You are using FCKeditor.

"""
print oFCKeditor.Create()
except Exception, e:
print e
print """




"""

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

# Document footer
print """


"""

"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.
阅读(876) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-11-05 08:38:22

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com