FAQ

Le Thu, 17 Feb 2005 19:22:16 +0100, Thomas Heller a ?crit?:

I am trying to use the function "CreateStreamOnHGlobal" from python code
(I need to pass an IStream object to MSXML, like I do in C++ code).

I was able to retrieve a pointer on the IStream object in this way:

from ctypes import *

stream = c_int()
windll.ole32.CreateStreamOnHGlobal(c_long(0), c_long(1), byref(stream))
print "%x"%stream.value

The problem is that I would like to attach this pointer to a python
IDispatch object (in Python only, not using a C++ DLL to do the stuff).
Do you know a way to do it ?
What do you want to do with this pointer? Pass it to a function called via
ctypes?

Once it is a IDispatch object (like the IDispatch object returned by
"win32com.client.Dispatch"), I will call the IStream methods on it and
pass it to a DOMDocument of MSXML. It should look like that:

stream = c_int()
windll.ole32.CreateStreamOnHGlobal(c_long(0), c_long(1), byref(stream))
stream_obj = some_conversion(stream)
# IDispatch call
stream_obj.Write("some data", 9)

doc = win32com.client.Dispatch("MSXML2.DOMDocument.4.0")
doc.load(stream_obj)



From http Thu Feb 17 22:27:06 2005
From: http (Paul Rubin)
Date: 17 Feb 2005 13:27:06 -0800
Subject: low-end persistence strategies?
References: <7xll9pus7o.fsf_-_@ruckus.brouhaha.com>
<4214f9ba$0$832$8fcfb975@news.wanadoo.fr>
<mailman.2774.1108674135.22381.python-list@python.org>
Message-ID: <7xr7jezxlh.fsf@ruckus.brouhaha.com>

John Lenton <john at grulic.org.ar> writes:
Maybe you'll find this too naive, but why do you want to avoid
concurrent accesses to a database that will be accessed 12 times a day ?
because every sunday at 3am your boss and his wife will both try to
use the script at the same time, and delete everything.
Yes, I think that could be pretty typical. For example, say I write a
cgi to maintain a signup list for a party I'm having. I email an
invitation out to some friends with a url to click if they want to
attend. If a dozen people click the url in the next day, several of
them will probably in the first minute or so after the email goes out.
So two simultaneous clicks isn't implausible.

More generally, I don't like writing code with bugs even if the bugs
have fairly low chance of causing trouble. So I'm looking for the
easiest way to do this kind of thing without bugs.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 3 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedFeb 17, '05 at 2:08p
activeFeb 17, '05 at 9:25p
posts3
users2
websitepython.org

2 users in discussion

Roger That: 2 posts Thomas Heller: 1 post

People

Translate

site design / logo © 2022 Grokbase