I. ASP
Think of ASP many people will say "asp language can not object-oriented, single function, many things can not be realized" and so on and so forth. The above statement is wrong, one ASp is not a language is used by Microsoft to replace the CGI of a web framework, but we have been distorted in the vbs is the default language of asp, the ASP and vbs between the equator. The second Asp function is actually not a single web provides five objects (request, response, server, session, appliaction) which is inherent in the asp, in addition to these things are used by the Asp script level things. ASP with the help of a dynamic link library, in theory, you can try all the scripting languages, including (vbscript, jsscript, actionscript, perl, python), so ASP is a very rich and flexible web framework!
Second, why use python to write Asp
Python is in full swing these days, it's very hot, and it's holding its own in every major field, and naturally, it's also in the web. Echosong has used django, python's own web frameworks, and so on. Due to the work needs Echosong a large part of the time is in writing ASP. And vbs Asp really let people write a kind of want to die feeling, many functions with the help of a variety of c or other languages written by the dll stability is difficult to consider, and echosong and a Python a a pure shade (of some color) fan, started to contact python in 08 years has always been a hobby has not been broken, but just I have never used it for work.
III. Beginning to integrate the two little ones together
1, asp installation: with the installation of IIS asp has become the default installation of a good web framework
2. Install activepython: ActivePython is a specialized Python programming and debugging tool from ActiveState.
ActivePython includes a complete Python kernel that calls the official Python open-source kernel, an IDE for Python programming, some Windows extensions for Python, and full access to Windows APIs. ActivePython is not as open source as pure Python, but it can be downloaded for free. (Note that the version can only download 2.5, at first echosong also can not download the 2.7 version of the result of the ruthless 500 The reason is not clear, not enough 2.5 version is also enough to use)
3. Run C:\Python25\Lib\site-packages\win32comext\axscript\client\ on the command line;
4, to complete the above two steps you can start writing python Asp!
IV. Simple Demo
Connecting to database files (connecting to mssql database with pymssql)
<%import pymssql
class MSSQL:
def __init__(self,host,user,pwd,db):
= host
= user
= pwd
= db
def __GetConnect(self):
if not :
(NameError,"No connec Info")
= (host=,user=,password=,database=,charset="utf8")
cur = ()
if not cur:
(NameError,"connect Err")
else:
return cur
def getCur(self):
return self.__GetConnect()
def ExecQuery(self,sql):
cur = self.__GetConnect()
(sql)
resList = ()
()
return resList
def ExecNonQuery(self,sql):
cur = self.__GetConnect()
(sql)
()
()
gmssql = MSSQL(host="****",user="****",pwd="***",db="***")
gcur = ()
%>
Here Feel free to import python related modules!!!!
The data connection called by the file executes a sql statement that loops through the values of the fields to the page.
<%@LANGUAGE="python" CODEPAGE="65001"%>
<!--#include file=""-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Untitled document </title>
</head>
<body>
<%
resList = ("select admin_Id, admin_UserId from admin")
%>
<table>
<tr><td>admin number</td><td>admin account</td></tr>.
<%
for (admin_Id,admin_UserId) in resList:
(u"<tr><td>"+str(admin_Id)+"</td>")
(u"<td>"+str(admin_UserId)+"<td></tr>")
%>
</table>
</body>
</html>

V. Advantages of writing ASp in python
1, a high degree of code reuse: you can write your own project module, the usual common code Write a python module, and then all the server can be imported with the help of access to the
2, try python excellent features: python powerful Python library a lot of ready-made features directly, rather than wanting to traditional asp (vbs script) with the help of a lot of compiled line language dll to realize the
3, fully object-oriented: vbs is a process-oriented language, object features are very weak, many object-oriented ideas can not be used.
VI. Stability and performance considerations
Did a stress test The ability to handle transactions at the same time, the parameters are stronger than vbs, especially in the connection database with some python excellent open source pool processing module, so that many database bottlenecks to reduce. (The relevant data screenshots were not on this computer at the time of writing the blog post)