473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

PythonWin -- COM server won't change???

List:

I made a small change to a COM server under PythonWin.

I unregistered, then reregistered the server.

But the old version is still being invoked.

Did I miss a step:

Code follows.

Thanx
Charles
# cbLogger.py -- This logs messages to the specified file
# Originally simpleLogger.py. It's supposed to be
# more object oriented than the original
#
# This is modeled after SimpleCOMServer.py, from "Python Win32
# Programming" By Hammond and Robinson

from time import ctime
from time import time

class cbLogger:
defaultLogFile = r'C:\loggerTests\testLog.log'

def __init__(self, fileName = defaultLogFile, visible = 'no'):

# I'm hoping we can open the file . . maybe
try:
self.logFile = file(fileName, 'a')
except IOError:
self.logFile = None

# Any other exception is a fatal error,
# so we don't handle them.

# Good News! We've succeeded!
else:
self.__call__(self.__class__.__name__, \
'Log opened successfully')

def __del__(self):
self.__call__(self.__class__.__name__, 'Closing log file.')
self.logFile.close()
self.logFile = None

def logShow(self):
return 0

def __call__(self, caller = 'Unknown Caller', \
message = 'Unknown Message'):
self.logFile.write(ctime(time()) + ' <' + caller \
+ '> -- ' + message + '\n')
return 0

class cbCOMLogger:
# Wraps cbLogger in a COM object

# Note this is a kludge. It's the same as the wrapped class, but
# not sure how to make it so without copying it into a unicode
# string
defaultLogFile = u'C:\\loggerTests\\testLog.log'
_public_methods_ = ['open', 'close', 'logEntry', 'show']
_reg_progid_ = 'cbLogger.logServer'

# NEVER copy the following ID
# Use "print pythoncom.CreateGuid()" to make a new one
_reg_clsid_ = "{4BBB5C62-C460-43C5-82A4-52FD373A7D2A}"

def __init__(self):
self.fileOpen = False

def open(self, fileName = defaultLogFile, visible = u'no'):
if self.fileOpen == False:
self.__Logger = cbLogger(str(fileName), str(visible))
self.fileOpen = True
return 0
else:
return -1

def close(self):
if self.fileOpen == True:
del self.__Logger
self.fileOpen = False

return 0

def logShow(self):
return 0

def logEntry(self, caller = u'Unknown Caller', \
message = u'Unknown Message'):
if self.fileOpen == True:
return self.__Logger(str(caller), str(message))
else:
return -1

def __del__(self):
if self.fileOpen == True:
self.close()

return 0

# Add code so that when this script is run by
# Python.exe, it self-registers.
if __name__=='__main__':
print "Registering COM server..."
import win32com.server.register
win32com.server.register.UseCommandLine(cbCOMLogge r)

Jul 18 '05 #1
2 1494
U-CDK_CHARLES\Charles wrote:
List:

I made a small change to a COM server under PythonWin.

I unregistered, then reregistered the server.

But the old version is still being invoked.

Did I miss a step:

Code follows.

Well, for example, if it's currently mapped into a process you'll have
to somehow get that process to reload() the module. I can't remember
offhand what the default is, btu I know that the only way I can pick up
a re-registered object under IIS is to have a web page import and then
reload() the module that the COM server is defined in. Kinda yucky, but
it works, don't know whether it'll help you.

regards
Steve
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
Jul 18 '05 #2
On Sat, 30 Oct 2004 03:04:27 -0400, Steve Holden <st***@holdenweb.com>
wrote:
U-CDK_CHARLES\Charles wrote:
List:

I made a small change to a COM server under PythonWin.

I unregistered, then reregistered the server.

But the old version is still being invoked.

Did I miss a step:

Code follows.

Well, for example, if it's currently mapped into a process you'll have
to somehow get that process to reload() the module. I can't remember
offhand what the default is, btu I know that the only way I can pick up
a re-registered object under IIS is to have a web page import and then
reload() the module that the COM server is defined in. Kinda yucky, but
it works, don't know whether it'll help you.


AH!! . . Exactly!!

I was invoking it from a VB program, and changed it while my program was
open in the IDE.

All is well.

Thanx

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: R.Marquez | last post by:
I uninstalled my 2.2.2 version of Python and related packages from my XP Professional station and proceeded to upgrade to the latest and greatest: Python2.3, win32all-155.exe, etc. When I try to...
1
by: Conrad | last post by:
Greetings, I have some simple printing I need to do from Python on Windows, so I opted for the excellent PyCDC methods. I got stumped when I realized that I actually needed something other...
6
by: Anders Eriksson | last post by:
Hello! I'm using ActivePython 2.3.2 build 232 on Windows 2000 and I have noticed a strange behavior in PythonWin IDE (win32all build 163) I'm from Sweden and we have a couple of letters in our...
1
by: Glenn Reed | last post by:
Hi, Someone might be able to help me with this. If I am using PythonWin (as part of the ActiveState Python distribution) (lastest release 2.2) and have two files in the editor window. ----...
4
by: Colin J. Williams | last post by:
PythonWin has been my favourite IDE for quite a while. When one right clicks on a .py file in the Windows Explorer, among the options are Open and Edit. The former is the default and executes...
3
by: Tuure Laurinolli | last post by:
Some time ago I was playing with the idea of using an actual IDE to write my python code. I first played with IDLE, but noticed that it was kind of limited and for some reason it worked extremely...
14
by: Jive | last post by:
I've un-installed Python 2.4, re-installed Python 2.3 and PythonWin for 2.3, but it's still broke. When I start PythonWin, sometimes it looks like it is going to be okay. But as soon as I open...
4
by: Chris P. | last post by:
I've been having a problem with PythonWin that seemed to start completely spontaneously and I don't even know where to START to find the answer. The only thing I can think of that marks the point...
3
by: tkpmep | last post by:
I have a Python program that collects user input using msg = "Enter the full path and name of the file to be processed: " answer = raw_input(msg) If I run it in IDLE, the question is splashed...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.