[python-win32] Marking a Python COM server safe for InternetExplorer

Craig H. Anderson craig at coot.net
Wed Aug 11 17:25:40 CEST 2004


Mark is correct.  Server side ASP vbscript can use the Python
COM object just fine.  After a good night's sleep I
tried another test and everything works fine.
I'll tack my test code on the end. 

> Mark Hammond wrote:
> If they are calling it from ASP, then there should be no need to implement
> this interface.  Any COM object should work.  AFAIK, there is only an issue
> when trying to run it on the client.

######################## ComTest.py
class ComTestPy:
   _reg_progid_ = "Gcspython.ComTestPy"
   # use "print pythoncom.CreateGuid()"
   _reg_clsid_ = "{723745E2-B43F-46F7-A799-5EA990D1893E}"
   _public_methods_ = ["Echo","GetList"]
   _public_attrs_ = ["Version"]
   _readonly_attrs_ = ["Version"]
   def __init__(self):
       print 'ComTestPy.__init__'
       self.Version = "MyVersion"
   def Echo(self,msg):
       return 'Echo: %s' % str(msg)
   def GetList(self,listName):
       retList = []
       retList.append('You requested list: %s' % listName)
       retList.append('1')
       retList.append('2')
       retList.append('3')
       return retList

# Registration support.
if __name__=='__main__':
   import win32com.server.register
   win32com.server.register.UseCommandLine(ComTestPy) 

######################## TestPythonCom.asp
<html>
<head>
<title>Test of Python Com</title>
</head>
<body>
<%
Dim comObj,rslt,echo,listRslt
Set comObj = CreateObject("Gcspython.ComTestPy")
rslt = comObj.Version
echo = comObj.Echo("From Asp")
listRslt = comObj.GetList("Active List")
%>
ComObj Version is <%=rslt%> <br>
ComObj echo is <%=echo%> <br> 

ComObj listRslt is
<%For i = LBound(listRslt) to UBound(listRslt)%>
<%=listRslt(i)%> ,
<%Next%>
<br> 

</body>
</html> 

######################## Output is
ComObj Version is MyVersion
ComObj echo is Echo: From Asp
ComObj listRslt is You requested list: Active List , 1 , 2 , 3 , 


More information about the Python-win32 mailing list