Help with a Python ASP C extension module ...

logistix logstx at bellatlantic.net
Sat Mar 16 15:59:26 EST 2002


I've had to build some COM components that do this.  There are two ways to
do it.  The easy way and the right way.  (sorry examples are in VB, they've
got these darn "corporate standards")

The easy way create a function that let's you pass in the response object
and capture it.  Then on the script side:

<%
Dim foo
Set foo = Server.CreateObject("foo.bar")
Set foo.response = Response

foo.otherMethod("ttt") ' can access foo's internal copy of response.
%>

The right way is to grab a reference to the Response Object via MTS.  It's
not really that hard, there are just a few more steps involved.  Here's the
code I reference for that:

http://www.microsoft.com/mind/0999/vbcom/vbcomtextfigs.htm#fig14

Of course VB is nice enough to provide wierd wrapper objects to prevent you
from understanding what's really going on ;)  Hopefully it's a
straightforward translation to Component instantiation.

<rant>
If you haven't dealt with COM components in C before, get ready for a rude
awakening.  That's what finally turned me off to C++.  You have to jump
through hoop after hoop after hoop just to deliver on C++'s promise of
"reusable objects"
</rant>
--
-

"Eric Vasilik" <eric at vasilik.com> wrote in message
news:40ee0487.0203152316.70c12a49 at posting.google.com...
> I am writing a C extension to Python.  The reason I am writing an
> extension is that I believe that the implementation of
> Response.BinaryWrite() in the Window's ASP extension (I am using
> Active State's Python 2.1) is not releasing the global interpreter
> lock.  I am getting very poor performace using it and I believe that
> my server is not taking advantage of writing out multiple streams
> because of the global lock.
>
> Instead of writing out a response with:
>
>     Response.BinaryWrite( buffer( open( fileName, 'rb' ).read() ) )
>
> I am now doing the following:
>
>     PythonExt.binaryWriteFile( Response, fileName )
>
> The difference between these two is that the first calls the default
> implementation of Response.BinaryWrite and the second calls an
> extension I have written which reads the file and writes it out to
> response, all while the interpreter lock is released.
>
> My problem, is I cannot find any documentation on how to get a hold of
> the IResponse object from the Python Response object.  I need to get
> it so that I may call BinaryWrite on without going back into the
> Python interpreter.
>
> I thought I would be able to find the source for the Response object
> with the source from Active State, or the source from Mark Hammond's
> win32All, but I found no references there.  Any help would be
> appreciated.





More information about the Python-list mailing list