Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DDE in Python

3,161 views
Skip to first unread message

rad...@my-dejanews.com

unread,
Sep 4, 1998, 3:00:00 AM9/4/98
to
"Toby Dickenson" <ht...@tcp.co.uk> wrote in article
<35a49bd1....@news.tcp.co.uk>...
> Ive programmed some DDE quite intensively a while back,
> and I am willing to have a look.
> What are the outstanding issues?

Is DDE support fully available in win32all-108? : ->

I've just downloaded Win32all-108 (beta version) of the new
PythonWin and extensions. Looking at the imports from
import dde I notice that I might be able to create a DDE
server in Python. What I am doing looks like this:

from dde import *
ddeServer = CreateServer()
ddeTopic = CreateTopic("Reservation")
ddeStringItem = CreateStringItem("Pnr")
ddeTopic.AddItem(ddeStringItem)
ddeServer.Create('Res_Server')

At this point I get following error message:
'Error: the server could not be created'
typing 'ddeServer.GetLastError()' returns 16387

Varying the order of the calls does not change
anything. Testing for the GetLastError on the
call ddeServer = CreateServer()

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum

Greg Stein

unread,
Sep 5, 1998, 3:00:00 AM9/5/98
to
rad...@my-dejanews.com wrote in message <6sp1bh$vum$1...@nnrp1.dejanews.com>...

>"Toby Dickenson" <ht...@tcp.co.uk> wrote in article
><35a49bd1....@news.tcp.co.uk>...
>> Ive programmed some DDE quite intensively a while back,
>> and I am willing to have a look.
>> What are the outstanding issues?
>
>Is DDE support fully available in win32all-108? : ->
>...


If COM is an acceptable alternative, then win32all definitely supports it
:-)

(DDE is generally deprecated, I believe)

--
Greg Stein (gst...@lyra.org)


Robin Becker

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to
In article <6st9v3$bbd$1...@supernews.com>, Greg Stein <gst...@lyra.org>
writes
Who by? MS deprecates anything that already works for fairly obvious
commercial reasons. DDE works for several huge financial data
distribution programs and is a lowest common denominator. It's much
easier to understand and has a smaller footprint than the more
experimental alternatives. Commercial interests will keep the bleeding
edge sharp as long as masochists are willing to cut themselves.
Concentrate on robustness not cuteness. End ramble.
--
Robin Becker

Christian Tismer

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to
Greg Stein wrote:
>
> rad...@my-dejanews.com wrote in message <6sp1bh$vum$1...@nnrp1.dejanews.com>...
> >"Toby Dickenson" <ht...@tcp.co.uk> wrote in article
> ><35a49bd1....@news.tcp.co.uk>...
> >> Ive programmed some DDE quite intensively a while back,
> >> and I am willing to have a look.
> >> What are the outstanding issues?
> >
> >Is DDE support fully available in win32all-108? : ->
> >...
>
> If COM is an acceptable alternative, then win32all definitely supports it
> :-)
>
> (DDE is generally deprecated, I believe)

No, this is a wish which I share, but it is very alive, due to
Netscape. If you want to control Netscape locally, and you don't
have a HTTP server and want to communicate with it without doing
everything through plugins and applets, you have to use DDE.

A DDE client is needed to push Netscape to show an URL in some
window. I got this to work with a modified version of Sam's windde
module.
For the opposite way: Netscape requesting pages from your Python app,
it is necessary to become a DDE server and to register a new protocol.
This is my current problem. I looked into the win32 source code.
DDE is supported complete internally, but just a few methods are
exposed to Python. Especially DDE-Request and DDE-Poke are missing.

This all is not needed for MSIE since it ahs a very complete COM
interface. But my testing showed the good news: Both NS and MSIE
support the DDE implementation of the NSAPI, so I am sure it is
possible to write a local HTTP surrogate with this.

The result of this would be:
Applications can make use of "any" (MSIE, NS, Opera,...) browser
as a GUI, regardless wether the server process is a true server
(using http) or a local process (using the surrogate).

This is where I'm hacking on for my current project.

cheers - pirx

--
Christian Tismer :^) <mailto:tis...@appliedbiometrics.com>
Applied Biometrics GmbH : Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101 : *Starship* http://starship.skyport.net
10553 Berlin : PGP key -> http://pgp.ai.mit.edu/
we're tired of banana software - shipped green, ripens at home

rad...@my-dejanews.com

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to
In article <6st9v3$bbd$1...@supernews.com>,

"Greg Stein" <gst...@lyra.org> wrote:
> If COM is an acceptable alternative, then win32all definitely supports it
> :-)
>
> (DDE is generally deprecated, I believe)
>
> --
> Greg Stein (gst...@lyra.org)
>
>
DDE is deprecated by Microsoft but it's still in use in a huge
number of applications (including new ones!). I've got to write
a DDE-Socket server which should communicate with a PC based
backoffice system (which uses DDE exclusively for communication)
and transfer the data pushed by the backoffice application to
an AS/400 system using sockets.

It may seem that this is partly "deprecated" technology but the
truth is that DDE is pretty robust and is generally simpler
thank a lot of other interfaces.

I could write the software in Visual Basic but I'd much prefer
doing it in CPython on the PC side. The AS/400 does not have
a C compiler so I can forget writing the socket server in

rad...@my-dejanews.com

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to
In article <6st9v3$bbd$1...@supernews.com>,
"Greg Stein" <gst...@lyra.org> wrote:
> If COM is an acceptable alternative, then win32all definitely supports it
> :-)
>
> (DDE is generally deprecated, I believe)
>
> --
> Greg Stein (gst...@lyra.org)
>
>
DDE is deprecated by Microsoft but it's still in use in a huge
number of applications (including new ones!). I've got to write
a DDE-Socket server which should communicate with a PC based
backoffice system (which uses DDE exclusively for communication)
and transfer the data pushed by the backoffice application to
an AS/400 system using sockets.

It may seem that this is partly "deprecated" technology but the
truth is that DDE is pretty robust and is generally simpler
thank a lot of other interfaces.

I could write the software in Visual Basic but I'd much prefer
doing it in CPython on the PC side. The AS/400 does not have

a C compiler so I can forget writing the socket server in C
as an AS/400 C compil

rad...@my-dejanews.com

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to
In article <6st9v3$bbd$1...@supernews.com>,
"Greg Stein" <gst...@lyra.org> wrote:
> If COM is an acceptable alternative, then win32all definitely supports it
> :-)
>
> (DDE is generally deprecated, I believe)
>
> --
> Greg Stein (gst...@lyra.org)
>
>
DDE is deprecated by Microsoft but it's still in use in a huge
number of applications (including new ones!). I've got to write
a DDE-Socket server which should communicate with a PC based
backoffice system (which uses DDE exclusively for communication)
and transfer the data pushed by the backoffice application to
an AS/400 system using sockets.

It may seem that this is partly "deprecated" technology but the
truth is that DDE is pretty robust and is generally simpler
thank a lot of other interfaces.

I could write the software in Visual Basic but I'd much prefer
doing it in CPython on the PC side. The AS/400 does not have
a C compiler so I can forget writing the socket server in C

as an AS/400 C compiler license costs ca. $15,000!

My plan on the AS/400 side is installing IBM's java toolkit
and trying to then load the JPython core onto it. Now that
would be fun 8-)
Anyway-> I've got a server model going under CPython
(just haven't figured out how to handle callbacks from it)
as I'd like my CPython DDE server to handle "wild requests"
i.e. I don't want to register my DDE Service by name but
want to be explicitly called by Topic.
Any help handling DDE using CPython would be greatly
appreciated!!!
--
Florent Heyworth

Mark Hammond

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to
>Is DDE support fully available in win32all-108? : ->

Yes it is. Pythonwin now uses it so that if you right-click on a .py file
and select "Edit", and existing Pythonwin will open the file. Further, you
can use DDE to get Pythonwin to execute arbitary Python code - the DDE
string sent is actually just arbitary code executed by the running Pythonwin
(what do you mean "security"? :-)

But Im afraid Im not experienced enought with DDE to answer your questions.
All I know is that the Pythonwin support lives in "intpydde.py", and that
works fine :-)

Mark.


Christian Tismer

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to
[...]

[yes DDE is more alive than we like]

> I could write the software in Visual Basic but I'd much prefer
> doing it in CPython on the PC side. The AS/400 does not have
> a C compiler so I can forget writing the socket server in

Do you need a client, server, or both? To what extent?
If you are fine with dde_execute and dde_request, I can help you.
WIth the server part, I'm in the very beginning.

Christian Tismer

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to
[snip snap]

> Server:
> - server receives all DDE requests sent to a particular service/topic
>
> Client:
> - client deals with dde_execute and dde_request
>
> On the server side I coded the following test code in the Python
> interpreter:
> import win32ui
> import dde
>
> server = dde.CreateServer()
> server.AddTopic(dde.CreateServerSystemTopic())
> server.AddTopic(dde.CreateTopic('RunAnyCommand'))
> server.Create('RunAny')

this already breaks for me. "error: The server could not be created"

must "RunAny" be define somewhere else?

> On the client side I can write:
> import windde
> client = windde.dde_session()
> client.initialize()
> client.connect('','RunAnyCommand')
>
> and that works fine. My problem is I'm not sure where to take it from there.
>
> I've got to worry deal with callbacks and finding out when the server has
> been connected to. I can't seem to get the execute statement to work.

At least I can tell you about the client side.
In windll, add the following to the class dde_session:

def request (self, command):
htext = dde_string(self, command)
result = windll.membuf(4)
retval = user32.DdeClientTransaction (
0, # pData
0x0, # cbData
self.conversation, # hConv
htext, # hszItem
CF_TEXT, # wFmt
XTYP_REQUEST, # wType
10000, # dwTimeout
result # pdwResult
)
if not retval:
self.hurl ('DdeClientTransaction')
else:
return struct.unpack ('l', result.read())[0]

Then you have at least a way to control Nestcape which relies on
dde_request:

>>> import dynwin
>>> import windde2 # with the above addition
>>> s=windde2.dde_session()
>>> s.initialize()
>>> s.connect("NETSCAPE", "WWW_OpenURL")
>>> s.request("http://starship.skyport.net")
1953785890
>>>

This takes my browser where it should.
For more, we have to work on the callback function. As you can see,
Sam already prepared a dummy callback func in windde.
I think with some more hours of trying, this could work as well.

cheers - chris

Florent Heyworth

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to Christian Tismer
Christian Tismer wrote:

> [...]
>
> [yes DDE is more alive than we like]
>
> > I could write the software in Visual Basic but I'd much prefer
> > doing it in CPython on the PC side. The AS/400 does not have
> > a C compiler so I can forget writing the socket server in
>
> Do you need a client, server, or both? To what extent?
> If you are fine with dde_execute and dde_request, I can help you.
> WIth the server part, I'm in the very beginning.

Hi

what I actually need is a DDE client/server application. It would basically
work like
this:

Server:
- server receives all DDE requests sent to a particular service/topic

Client:
- client deals with dde_execute and dde_request

On the server side I coded the following test code in the Python
interpreter:
import win32ui
import dde

server = dde.CreateServer()
server.AddTopic(dde.CreateServerSystemTopic())
server.AddTopic(dde.CreateTopic('RunAnyCommand')

server.Create('RunAny')

On the client side I can write:
import windde
client = windde.dde_session()
client.initialize()
client.connect('','RunAnyCommand')

and that works fine. My problem is I'm not sure where to take it from there.

I've got to worry deal with callbacks and finding out when the server has
been connected to. I can't seem to get the execute statement to work.

Any help concerning either the client or the server part would be greatly
appreciated 8-)

Florent Heyworth

Florent Heyworth

unread,
Sep 6, 1998, 3:00:00 AM9/6/98
to Christian Tismer

Mark Hammond

unread,
Sep 7, 1998, 3:00:00 AM9/7/98
to
Here is (yet another undocumented) DDE sample. It basically takes your
code, and makes it work with the Pythonwin DDE module.

Now I _definately_ have no more time to look at this :-)

Mark.


ddeclient.py
ddeserver.py

Julien System Oster

unread,
Sep 7, 1998, 3:00:00 AM9/7/98
to
"Robin" == Robin Becker <ro...@jessikat.demon.co.uk> writes:

> Who by? MS deprecates anything that already works for fairly obvious
> commercial reasons. DDE works for several huge financial data distribution
> programs and is a lowest common denominator. It's much easier to understand
> and has a smaller footprint than the more experimental
> alternatives. Commercial interests will keep the bleeding edge sharp as long
> as masochists are willing to cut themselves. Concentrate on robustness not
> cuteness. End ramble. -- Robin Becker

I personally like "portable" solution. That is, in this case, somebody could
make a module which is an Interface to the COM module *and* the DDE modules.
So, everybody is satisfied.

As I already mentioned, the same counts especially for application GUIs which
don't necessarely needs graphics. Supporting ncurses and Tk (if you'd like to
also KDE, GTK and Motif) should satisfy everyone, though I haven't made a
module for supporting all those GUI Interfaces. I simply make my programs so,
that the GUI is (mostly) a more or less separated part of the program and make
different versions for different Interfaces for it.

--
Julien Oster <sys...@sysadm.cc>
.+'''+. .+'''+. .+'''+.
---+-------+-------+-------+-------+-------+---
.' `+.,.+' '+.,.+' '.

rog...@aol.com

unread,
Sep 7, 1998, 3:00:00 AM9/7/98
to
In article <TyGF7RAe...@jessikat.demon.co.uk>,

Robin Becker <ro...@jessikat.demon.co.uk> wrote:
> In article <6st9v3$bbd$1...@supernews.com>, Greg Stein <gst...@lyra.org>
> writes

> >rad...@my-dejanews.com wrote in message <6sp1bh$vum$1...@nnrp1.dejanews.com>...
> >>"Toby Dickenson" <ht...@tcp.co.uk> wrote in article
> >><35a49bd1....@news.tcp.co.uk>...
> >>> Ive programmed some DDE quite intensively a while back,
> >>> and I am willing to have a look.
> >>> What are the outstanding issues?
> >>
> >>Is DDE support fully available in win32all-108? : ->
> >>...

> >
> >
> >If COM is an acceptable alternative, then win32all definitely supports it
> >:-)
> >
> >(DDE is generally deprecated, I believe)
> >
> >--
> >Greg Stein (gst...@lyra.org)
> >
> Who by? MS deprecates anything that already works for fairly obvious
> commercial reasons. DDE works for several huge financial data
> distribution programs and is a lowest common denominator. It's much
> easier to understand and has a smaller footprint than the more
> experimental alternatives. Commercial interests will keep the bleeding
> edge sharp as long as masochists are willing to cut themselves.
> Concentrate on robustness not cuteness. End ramble.
> --
> Robin Becker
>

I agree completely with Robin. DDE should be the method of choice for what
its name implies, Data Exchange. There is no way Microsoft can stop
supporting it. See the web site for a tool that could help you.

Roger Abbott
RHA (Minisystems) Ltd.
http://www.angelfire.com/biz/rhaminisys

0 new messages