#!/usr/bin/env python
"""
FCKeditor - The text editor for internet
Copyright (C) 2003-2006 Frederico Caldeira Knabben
Licensed under the terms of the GNU Lesser General Public License:
http://www.opensource.org/licenses/lgpl-license.php
For further information visit:
http://www.fckeditor.net/
"Support Open Source software. What about a donation today?"
File Name: connector.py
Connector for Python.
Tested With:
Standard:
Python 2.3.3
Zope:
Zope Version: (Zope 2.8.1-final, python 2.3.5, linux2)
Python Version: 2.3.5 (#4, Mar 10 2005, 01:40:25)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)]
System Platform: linux2
File Authors:
Andrew Liu (andrew@liuholdings.com)
"""
"""
Author Notes (04 December 2005):
This module has gone through quite a few phases of change. Obviously,
I am only supporting that part of the code that I use. Initially
I had the upload directory as a part of zope (ie. uploading files
directly into Zope), before realising that there were too many
complex intricacies within Zope to deal with. Zope is one ugly piece
of code. So I decided to complement Zope by an Apache server (which
I had running anyway, and doing nothing). So I mapped all uploads
from an arbitrary server directory to an arbitrary web directory.
All the FCKeditor uploading occurred this way, and I didn't have to
stuff around with fiddling with Zope objects and the like (which are
terribly complex and something you don't want to do - trust me).
Maybe a Zope expert can touch up the Zope components. In the end,
I had FCKeditor loaded in Zope (probably a bad idea as well), and
I replaced the connector.py with an alias to a server module.
Right now, all Zope components will simple remain as is because
I've had enough of Zope.
See notes right at the end of this file for how I aliased out of Zope.
Anyway, most of you probably wont use Zope, so things are pretty
simple in that regard.
Typically, SERVER_DIR is the root of WEB_DIR (not necessarily).
Most definitely, SERVER_USERFILES_DIR points to WEB_USERFILES_DIR.
"""
import cgi
import re
import os
import string
"""
escape
Converts the special characters '<', '>', and '&'.
RFC 1866 specifies that these characters be represented
in HTML as < > and & respectively. In Python
1.5 we use the new string.replace() function for speed.
"""
def escape(text, replace=string.replace):
text = replace(text, '&', '&') # must be done 1st
text = replace(text, '<', '<')
text = replace(text, '>', '>')
text = replace(text, '"', '"')
return text
"""
getFCKeditorConnector
Creates a new instance of an FCKeditorConnector, and runs it
"""
def getFCKeditorConnector(context=None):
# Called from Zope. Passes the context through
connector = FCKeditorConnector(context=context)
return connector.run()
"""
FCKeditorRequest
A wrapper around the request object
Can handle normal CGI request, or a Zope request
Extend as required
"""
class FCKeditorRequest(object):
def __init__(self, context=None):
if (context is not None):
r = context.REQUEST
else:
r = cgi.FieldStorage()
self.context = context
self.request = r
def isZope(self):
if (self.context is not None):
return True
return False
def has_key(self, key):
return self.request.has_key(key)
def get(self, key, default=None):
value = None
if (self.isZope()):
value = self.request.get(key, default)
else:
if key in self.request.keys():
value = self.request[key].value
else:
value = default
return value
"""
FCKeditorConnector
The connector class
"""
class FCKeditorConnector(object):
# Configuration for FCKEditor
# can point to another server here, if linked correctly
#WEB_HOST = "http://127.0.0.1/"
WEB_HOST = ""
SERVER_DIR = "/var/www/html/"
WEB_USERFILES_FOLDER = WEB_HOST + "upload/"
SERVER_USERFILES_FOLDER = SERVER_DIR + "upload/"
# Allow access (Zope)
__allow_access_to_unprotected_subobjects__ = 1
# Class Attributes
parentFolderRe = re.compile("[\/][^\/]+[\/]?$")
"""
Constructor
"""
def __init__(self, context=None):
# The given root path will NOT be shown to the user
# Only the userFilesPath will be shown
# Instance Attributes
self.context = context
self.request = FCKeditorRequest(context=context)
self.rootPath = self.SERVER_DIR
self.userFilesFolder = self.SERVER_USERFILES_FOLDER
self.webUserFilesFolder = self.WEB_USERFILES_FOLDER
# Enables / Disables the connector
self.enabled = False # Set to True to enable this connector
# These are instance variables
self.zopeRootContext = None
self.zopeUploadContext = None
# Copied from php module =)
self.allowedExtensions = {
"File": None,
"Image": None,
"Flash": None,
"Media": None
}
self.deniedExtensions = {
"File": [ "php","php2","php3","php4","php5","phtml","pwml","inc","asp","aspx","ascx","jsp","cfm","cfc","pl","bat","exe","com","dll","vbs","js","reg","cgi","htaccess" ],
"Image": [ "php","php2","php3","php4","php5","phtml","pwml","inc","asp","aspx","ascx","jsp","cfm","cfc","pl","bat","exe","com","dll","vbs","js","reg","cgi","htaccess" ],
"Flash": [ "php","php2","php3","php4","php5","phtml","pwml","inc","asp","aspx","ascx","jsp","cfm","cfc","pl","bat","exe","com","dll","vbs","js","reg","cgi","htaccess" ],
"Media": [ "php","php2","php3","php4","php5","phtml","pwml","inc","asp","aspx","ascx","jsp","cfm","cfc","pl","bat","exe","com","dll","vbs","js","reg","cgi","htaccess" ]
}
"""
Zope specific functions
"""
def isZope(self):
# The context object is the zope object
if (self.context is not None):
return True
return False
def getZopeRootContext(self):
if self.zopeRootContext is None:
self.zopeRootContext = self.context.getPhysicalRoot()
return self.zopeRootContext
def getZopeUploadContext(self):
if self.zopeUploadContext is None:
folderNames = self.userFilesFolder.split("/")
c = self.getZopeRootContext()
for folderName in folderNames:
if (folderName <> ""):
c = c[folderName]
self.zopeUploadContext = c
return self.zopeUploadContext
"""
Generic manipulation functions
"""
def getUserFilesFolder(self):
return self.userFilesFolder
def getWebUserFilesFolder(self):
return self.webUserFilesFolder
def getAllowedExtensions(self, resourceType):
return self.allowedExtensions[resourceType]
def getDeniedExtensions(self, resourceType):
return self.deniedExtensions[resourceType]
def removeFromStart(self, string, char):
return string.lstrip(char)
def removeFromEnd(self, string, char):
return string.rstrip(char)
def convertToXmlAttribute(self, value):
if (value is None):
value = ""
return escape(value)
def convertToPath(self, path):
if (path[-1] <> "/"):
return path + "/"
else:
return path
def getUrlFromPath(self, resourceType, path):
if (resourceType is None) or (resourceType == ''):
url = "%s%s" % (
self.removeFromEnd(self.getUserFilesFolder(), '/'),
path
)
else:
url = "%s%s%s" % (
self.getUserFilesFolder(),
resourceType,
path
)
return url
def getWebUrlFromPath(self, resourceType, path):
if (resourceType is None) or (resourceType == ''):
url = "%s%s" % (
self.removeFromEnd(self.getWebUserFilesFolder(), '/'),
path
)
else:
url = "%s%s%s" % (
self.getWebUserFilesFolder(),
resourceType,
path
)
return url
def removeExtension(self, fileName):
index = fileName.rindex(".")
newFileName = fileName[0:index]
return newFileName
def getExtension(self, fileName):
index = fileName.rindex(".") + 1
fileExtension = fileName[index:]
return fileExtension
def getParentFolder(self, folderPath):
asp.net 企业网站
需积分: 0 124 浏览量
更新于2011-07-26
收藏 14.84MB RAR 举报
【ASP.NET 企业网站开发详解】
ASP.NET 是微软公司推出的一种用于构建动态网站、Web 应用程序和服务的开发框架。它基于.NET Framework,提供了一种高效、安全且易于维护的平台,使得开发者能够快速地构建功能丰富的互联网应用。在这个“asp.net 企业网站”项目中,我们可以看到它被用于创建一个具备后台管理功能的完整企业级站点。
1. **运行环境:VS2010**
Visual Studio 2010是微软的集成开发环境(IDE),支持ASP.NET的开发。这个版本引入了对.NET Framework 4.0的支持,提供了更好的代码编辑、调试和项目管理工具,使得开发者可以更高效地编写和测试ASP.NET应用程序。在本项目中,所有代码和设计工作都在VS2010中完成,确保了开发过程的流畅性。
2. **ASP.NET Web Forms**
ASP.NET Web Forms是ASP.NET框架的一个重要组成部分,它允许开发者通过拖放控件和事件驱动编程模型来构建页面。在这个企业网站中,Web Forms可能被用来创建用户界面,如登录页面、产品展示页、新闻资讯等,每个Web Form对应一个独特的URL。
3. **ASP.NET MVC**
虽然没有明确提及,但考虑到企业级网站通常需要良好的结构和可测试性,ASP.NET MVC框架可能也被采用。MVC模式(Model-View-Controller)将应用程序逻辑分为三个部分,有助于实现松耦合和更高的代码复用。View负责显示数据,Controller处理用户交互,而Model则封装业务逻辑和数据。
4. **数据库集成**
企业级网站通常需要与数据库进行交互,存储和检索大量数据。ASP.NET提供ADO.NET服务,方便与各种数据库(如SQL Server)连接。开发者可能使用Entity Framework作为ORM(对象关系映射)工具,简化数据库操作。
5. **安全性**
ASP.NET 提供了内置的安全机制,如身份验证(Forms Authentication)、授权(Role-Based Authorization)和会话管理,确保只有经过验证的用户能访问特定资源。在后台管理系统中,这些特性尤为重要,以保护敏感信息。
6. **状态管理**
ASP.NET 提供多种状态管理选项,如视图状态、控制状态、隐藏字段、查询字符串和Session,帮助开发者在Web的无状态环境中保持用户状态。
7. **部署与发布**
在VS2010中,可以轻松地打包和发布网站到IIS(Internet Information Services)服务器,实现网站的上线运行。
8. **用户体验优化**
使用CSS和JavaScript库(如jQuery)提升用户体验,实现页面动态加载、表单验证、AJAX调用等功能。
9. **性能与可伸缩性**
ASP.NET提供了缓存机制、HTTP模块和处理程序以及对负载均衡的支持,以应对高并发访问和大规模数据处理。
10. **维护与扩展**
企业网站应具有良好的架构和模块化设计,方便后期的维护和功能扩展。开发者可能遵循SOLID原则和设计模式,确保代码的可读性和可维护性。
总结,"asp.net 企业网站"项目展示了ASP.NET在构建复杂、高效且易于维护的Web应用中的强大能力。通过VS2010的开发环境,结合Web Forms或MVC,以及强大的数据库和安全功能,开发者能够构建出满足企业需求的定制化网站。这个项目中的源代码(fx)可能包含了上述所有技术的实现细节,对于学习和理解ASP.NET开发具有很高的参考价值。
变味奶茶
- 粉丝: 5
- 资源: 3
最新资源
- 搜广推推荐系统中传统推荐系统方法思维导图整理-完整版
- 微藻检测19-YOLO(v5至v11)、COCO、CreateML、Paligemma、TFRecord、VOC数据集合集.rar
- 使用AS的自定义功能块与OS之间WINCC自定义功能块图标,自定义功能块面板教程 1.不是采用西门子APL面板实现 2.AS可以采用LAD或者SCL语言生成功能块 3.实现弹窗功能 4.事件可
- 等发达地区的无穷大无穷大无穷大请问
- Python实现常见排序算法详解
- JWaaaaaaaaaaaaaaaaaaaa
- Python复制重复数据工具.exe
- 2024圣诞节海外消费市场趋势及营销策略分析报告
- 基于Java的网上教务评教管理系统的设计与实现.doc
- EventHandlerError解决办法.md
- NotImplementedError.md
- SecurityException(解决方案).md
- IllegalAccessException(解决方案).md
- NameError.md
- NSRunLoopError如何解决.md
- OSError.md