473,574 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:\loggerTest s\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__(s elf.__class__._ _name__, \
'Log opened successfully')

def __del__(self):
self.__call__(s elf.__class__._ _name__, 'Closing log file.')
self.logFile.cl ose()
self.logFile = None

def logShow(self):
return 0

def __call__(self, caller = 'Unknown Caller', \
message = 'Unknown Message'):
self.logFile.wr ite(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:\\loggerTes ts\\testLog.log '
_public_methods _ = ['open', 'close', 'logEntry', 'show']
_reg_progid_ = 'cbLogger.logSe rver'

# NEVER copy the following ID
# Use "print pythoncom.Creat eGuid()" 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(fi leName), 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(s tr(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__=='__ma in__':
print "Registerin g COM server..."
import win32com.server .register
win32com.server .register.UseCo mmandLine(cbCOM Logger)

Jul 18 '05 #1
2 1514
U-CDK_CHARLES\Cha rles 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***@holdenwe b.com>
wrote:
U-CDK_CHARLES\Cha rles 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
2094
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 start the Pythonwin editor, either through its shortcut or through right clicking on an existing module, a window pops up with the message: <Error...
1
3008
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 than left-justified printing for this project. PyCDC.DrawText appears to offer what I need, but the doc at:
6
2236
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 alphabet that isn't part of ASCII and the strangeness is about one of them When I use the letter å (&aring;) then the next character is eaten!...
1
1500
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. ---- module1.py -------- class module1: def __init__(self): self.x=23
4
2434
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 Python, with the selected script. The latter activates the PythonWin editor, with the selected script. Since, most frequently, I wish to edit the...
3
1933
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 slowly when started from a shortcut on desktop(not so when started from shortcut in start menu). Then I tried Pythonwin and noticed that it didn't...
14
2877
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 a .py file, the interactive window grabs the focus and will not let go. I am stumped. Is there something PythonWin uses that I could try...
4
2602
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 between "PythonWin works fine" and "PythonWin hardly every works fine" was that I changed the size of my Virtual Paging file, noticing that it was...
3
3334
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 across the execution window, and if it is long, simply wraps to the next line. Most importantly, it is intelligible, because I see the entire...
0
8040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7800
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8092
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6437
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5610
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3745
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2230
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.