[Tutor] server won't register because attribute win32com.server not found

Mallett, Roger rmallett@rational.com
Wed, 3 Jan 2001 17:21:59 -0800


Operating System:  Window 2000, Service Pack 1

Using PythonWin, Active Python, build 202


I can't seem to register the python COM server below.  The code I am using
comes from pp 102-103 of Mark Hammond's book "Programming on Win32".


As shown in the Interactive Session below, I get the error:
"AttributeError: server"

What might I be doing wrong?  (the code is below)

import win32com
class COMBookSet:
	_reg_clsid_ = '{A927B116-A485-479B-9084-EA59E99C8818}'
	_reg_progid_ = 'Doubletalk.BookServer'
	_public_methods_ = ['double']

	def __init__(self):
		self.__BookSet = doubletalk.bookset.Bookset()

	def double(self,arg):
		#trivial test function to check that it's alive
		return arg * 2

if __name__ == '__main__':
	win32com.server.register.UseCommandLine(COMBookSet)


(from Interactive Window)

>>> # getting a GUID for the server
>>> import pythoncom  # getting a guid for the server
>>> print pythoncom.CreateGuid()
{A927B116-A485-479B-9084-EA59E99C8818}
>>>
>>> # next I run the script listed above
>>>
Traceback (most recent call last):
  File "C:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in
RunScript
    exec codeObject in __main__.__dict__
  File "C:\Python20\win32\MyPythonScripts\comservers.py", line 14, in ?
    win32com.server.register.UseCommandLine(COMBookSet)
NameError: There is no variable named 'win32com'
Traceback (most recent call last):
  File "C:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in
RunScript
    exec codeObject in __main__.__dict__
  File "C:\Python20\win32\MyPythonScripts\comservers.py", line 15, in ?
    
AttributeError: server
>>>


Indeed, the server does not get registered.  I looked at the object browser
and located win32com.server.register.UserCommandLine, but it doesn't seem to
be located by Python.

Any assistance in this matter is greatly appreciated. 

Sincerely,

Roger Mallett