I am using a Pascal like language (Wealth-Lab) on W2K and call this server:
class HelloWorld:
_reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}"
_reg_desc_ = "Python Test COM Server"
_reg_progid_ = "Python.TestServer"
_public_methods_ = ['Hello']
_public_attrs_ = ['softspace', 'noCalls']
_readonly_attrs_ = ['noCalls']
def __init__(self):
self.softspace = 1
self.noCalls = 0
def Hello(self, WL ): # WL is an instance of a interface class that
exists in the client
# In VB this would look like Public Sub Hello(ByVal objWL As
WealthLab.IWealthLabAddOn3)
self.noCalls = self.noCalls + 1
# insert "softspace" number of spaces
return "Hello" + " " * self.softspace + str(self.noCalls) +
str(WL.BarCount())
if __name__=='__main__':
import win32com.server.register
win32com.server.register.UseCommandLine(HelloWorld )
How do I get the instance of the interface to have its methods? The Python
Trace Collector gives me:
Object with win32trace dispatcher created (object=None)
in _GetIDsOfNames_ with '('Hello',)' and '2048'
in _Invoke_ with 1002 0 3 (<PyIDispatch at 0x3c5efc4 with obj at 0x331ea00>)
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line
40, in _Invoke_
return self.policy._Invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 283,
in _Invoke_
return self._invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 288,
in _invoke_
return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 550,
in _invokeex_
return func(*args)
File "G:\Python\Dev\COM Server - win.py", line 27, in Hello
return "Hello" + " " * self.softspace + str(self.noCalls) +
str(WL.BarCount())
AttributeError: 'PyIDispatch' object has no attribute 'BarCount'
pythoncom error: Python error invoking COM method.
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line
129, in _Invoke_
return DispatcherBase._Invoke_(self, dispid, lcid, wFlags, args)
File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line
42, in _Invoke_
self._HandleException_()
File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line
107, in _HandleException_
reraise()
File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line
40, in _Invoke_
return self.policy._Invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 283,
in _Invoke_
return self._invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 288,
in _invoke_
return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 550,
in _invokeex_
return func(*args)
File "G:\Python\Dev\COM Server - win.py", line 27, in Hello
return "Hello" + " " * self.softspace + str(self.noCalls) +
str(WL.BarCount())
exceptions.AttributeError: 'PyIDispatch' object has no attribute 'BarCount'
in _Invoke_ with 0 1024 2 ()
in _Invoke_ with 0 1024 2 () 2 4528
You ought to be able to do
win32com.client.Dispatch(WL)
to get a usable com object.
hth
Roger
"Phil" <pr******@san.rr.com> wrote in message
news:rX***************@twister.socal.rr.com... I am using a Pascal like language (Wealth-Lab) on W2K and call this
server: class HelloWorld: _reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}" _reg_desc_ = "Python Test COM Server" _reg_progid_ = "Python.TestServer" _public_methods_ = ['Hello'] _public_attrs_ = ['softspace', 'noCalls'] _readonly_attrs_ = ['noCalls']
def __init__(self): self.softspace = 1 self.noCalls = 0
def Hello(self, WL ): # WL is an instance of a interface class that exists in the client # In VB this would look like Public Sub Hello(ByVal objWL As WealthLab.IWealthLabAddOn3) self.noCalls = self.noCalls + 1 # insert "softspace" number of spaces return "Hello" + " " * self.softspace + str(self.noCalls) + str(WL.BarCount())
if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(HelloWorld )
How do I get the instance of the interface to have its methods? The
Python Trace Collector gives me:
Object with win32trace dispatcher created (object=None) in _GetIDsOfNames_ with '('Hello',)' and '2048'
in _Invoke_ with 1002 0 3 (<PyIDispatch at 0x3c5efc4 with obj at
0x331ea00>) Traceback (most recent call last): File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line 40, in _Invoke_ return self.policy._Invoke_(dispid, lcid, wFlags, args) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line
283, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line
288, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None,
None) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line
550, in _invokeex_ return func(*args) File "G:\Python\Dev\COM Server - win.py", line 27, in Hello return "Hello" + " " * self.softspace + str(self.noCalls) + str(WL.BarCount()) AttributeError: 'PyIDispatch' object has no attribute 'BarCount' pythoncom error: Python error invoking COM method. Traceback (most recent call last): File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line 129, in _Invoke_ return DispatcherBase._Invoke_(self, dispid, lcid, wFlags, args) File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line 42, in _Invoke_ self._HandleException_() File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line 107, in _HandleException_ reraise() File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line 40, in _Invoke_ return self.policy._Invoke_(dispid, lcid, wFlags, args) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line
283, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line
288, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None,
None) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line
550, in _invokeex_ return func(*args) File "G:\Python\Dev\COM Server - win.py", line 27, in Hello return "Hello" + " " * self.softspace + str(self.noCalls) + str(WL.BarCount()) exceptions.AttributeError: 'PyIDispatch' object has no attribute
'BarCount' in _Invoke_ with 0 1024 2 () in _Invoke_ with 0 1024 2 ()
Hi Roger,
Thanks for the help. So now the program looks like:
import win32com.client
class HelloWorld:
_reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}"
_reg_desc_ = "Python Test COM Server"
_reg_progid_ = "Python.TestServer"
_public_methods_ = ['Hello']
_public_attrs_ = ['softspace', 'noCalls']
_readonly_attrs_ = ['noCalls']
def __init__(self):
self.softspace = 1
self.noCalls = 0
def Hello(self, WL ):
# In VB this looks like Public Sub Hello(ByVal objWL As
WealthLab.IWealthLabAddOn3)
WL = win32com.client.Dispatch(WL)
self.noCalls = self.noCalls + 1
# insert "softspace" number of spaces
return "Hello" + " " * self.softspace + str(self.noCalls) +
str(WL.BarCount())
if __name__=='__main__':
import win32com.server.register
win32com.server.register.UseCommandLine(HelloWorld )
The Python Trace Collector gives me:
Object with win32trace dispatcher created (object=None)
in _GetIDsOfNames_ with '('Hello',)' and '2048'
in _Invoke_ with 1002 0 3 (<PyIDispatch at 0x3d91824 with obj at 0x32eea00>)
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line 40,
in _Invoke_
return self.policy._Invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 283, in
_Invoke_
return self._invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 288, in
_invoke_
return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 550, in
_invokeex_
return func(*args)
File "G:\Python\Dev\COM Server - win.py", line 27, in Hello
return "Hello" + " " * self.softspace + str(self.noCalls) +
str(WL.BarCount())
File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 489,
in __getattr__
raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: <unknown>.BarCount
pythoncom error: Python error invoking COM method.
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line
129, in _Invoke_
return DispatcherBase._Invoke_(self, dispid, lcid, wFlags, args)
File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line 42,
in _Invoke_
self._HandleException_()
File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line
107, in _HandleException_
reraise()
File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py", line 40,
in _Invoke_
return self.policy._Invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 283, in
_Invoke_
return self._invoke_(dispid, lcid, wFlags, args)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 288, in
_invoke_
return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None)
File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 550, in
_invokeex_
return func(*args)
File "G:\Python\Dev\COM Server - win.py", line 27, in Hello
return "Hello" + " " * self.softspace + str(self.noCalls) +
str(WL.BarCount())
File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 489,
in __getattr__
raise AttributeError, "%s.%s" % (self._username_, attr)
exceptions.AttributeError: <unknown>.BarCount
in _Invoke_ with 0 1024 2 ()
in _Invoke_ with 0 1024 2 ()
"Roger Upole" <ru****@hotmail.com> wrote in message
news:40********@127.0.0.1... You ought to be able to do win32com.client.Dispatch(WL) to get a usable com object. hth Roger
"Phil" <pr******@san.rr.com> wrote in message news:rX***************@twister.socal.rr.com... I am using a Pascal like language (Wealth-Lab) on W2K and call this server: class HelloWorld: _reg_clsid_ = "{4E797C6A-5969-402F-8101-9C95453CF8F6}" _reg_desc_ = "Python Test COM Server" _reg_progid_ = "Python.TestServer" _public_methods_ = ['Hello'] _public_attrs_ = ['softspace', 'noCalls'] _readonly_attrs_ = ['noCalls']
def __init__(self): self.softspace = 1 self.noCalls = 0
def Hello(self, WL ): # WL is an instance of a interface class that exists in the client # In VB this would look like Public Sub Hello(ByVal objWL As WealthLab.IWealthLabAddOn3) self.noCalls = self.noCalls + 1 # insert "softspace" number of spaces return "Hello" + " " * self.softspace + str(self.noCalls) + str(WL.BarCount())
if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(HelloWorld )
How do I get the instance of the interface to have its methods? The
Python Trace Collector gives me:
Object with win32trace dispatcher created (object=None) in _GetIDsOfNames_ with '('Hello',)' and '2048'
in _Invoke_ with 1002 0 3 (<PyIDispatch at 0x3c5efc4 with obj at 0x331ea00>) Traceback (most recent call last): File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py",
line 40, in _Invoke_ return self.policy._Invoke_(dispid, lcid, wFlags, args) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 283, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 288, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 550, in _invokeex_ return func(*args) File "G:\Python\Dev\COM Server - win.py", line 27, in Hello return "Hello" + " " * self.softspace + str(self.noCalls) + str(WL.BarCount()) AttributeError: 'PyIDispatch' object has no attribute 'BarCount' pythoncom error: Python error invoking COM method. Traceback (most recent call last): File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py",
line 129, in _Invoke_ return DispatcherBase._Invoke_(self, dispid, lcid, wFlags, args) File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py",
line 42, in _Invoke_ self._HandleException_() File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py",
line 107, in _HandleException_ reraise() File "C:\Python23\Lib\site-packages\win32com\server\dispatcher.py",
line 40, in _Invoke_ return self.policy._Invoke_(dispid, lcid, wFlags, args) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 283, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 288, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 550, in _invokeex_ return func(*args) File "G:\Python\Dev\COM Server - win.py", line 27, in Hello return "Hello" + " " * self.softspace + str(self.noCalls) + str(WL.BarCount()) exceptions.AttributeError: 'PyIDispatch' object has no attribute 'BarCount' in _Invoke_ with 0 1024 2 () in _Invoke_ with 0 1024 2 ()
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ken Allen |
last post by:
I am relatively new to .Net and C#, but I hav ebeen programing in other
languages and done some COM work for a number of years. I am attempting to
understand how to map an older program...
|
by: ALI-R |
last post by:
Hi All,
First of all I think this is gonna be one of those threads :-) since I have
bunch of questions which make this very controversial:-0)
Ok,Let's see:
I was reading an article that When...
|
by: znappa |
last post by:
Hi.
I would like to create an instance of a COM server from C# code.
I now use the System.Runtime.InteropServices.Marshal.GetActiveObject()
function to get the running instance (but this implies...
|
by: FS Liu |
last post by:
Hi,
In my current ATL server project, I have to parse the
input in the client application's request to find out
the different combination of parameters, instead of
using SOAP. For this reason,...
|
by: Brendan Reynolds |
last post by:
I'm trying to integrate SQL Server Reporting Services reports into an
ASP.NET app (SRS 2000, ASP.NET 1.1). I know how to do this using direct URL
addressing, but this exposes in the query string...
|
by: Mike |
last post by:
Hi,
I am strugling with a simple problem which I can't seem to resolve.
I have an asp.net page which contains a server-control (flytreeview,
which is a kind
of a tree to be exact).
The tree is...
|
by: Mały Piotru |
last post by:
Hello,
(sorry for my English...)
Could you help me please with installing SQL Servera 2005 Express
Edition. I downloaded files:
SQLEXPR.EXE - Microsoft SQL Server 2005 Express Edition...
|
by: Suresh |
last post by:
Hi Guys
I have Db2 server installed on remote server. i am connecting to that
remote server by using VPN.
I want to connect that remote DB2 server instance using my local
machine DB2...
|
by: eblackmo |
last post by:
I have a test network consisting of four servers running windows 2003 server R2 SP2. I have set up a domain which functioned correctly for about a day and a half until the other servers decided they...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |