Board index » delphi » Best way to have more than one unit for webbroker CGI / Isapi

Best way to have more than one unit for webbroker CGI / Isapi


2005-01-08 06:24:09 PM
delphi227
Hello all,
What's the best way to go to build a CGI / Isapi webbroker which returns a
respond with data from a SQL2000 Database.
The webbroker should be able to deal with 50+ requests every 30 seconds.
(due to update GPS coordinates and will give almost a real time track and
trace)
To make my code more managable I want to have functions in seperate
code-units like to set the connection and query commands.
I've noticed that when I add code-units to the project the for example
ADOConnection is not reachable (it will compile in code, but will fail in
runtime - the same with queries)
Any tips and advice is most welcome.
Thanks
Peter.
 
 

Re:Best way to have more than one unit for webbroker CGI / Isapi

With that many requests, CGI is probably not a good idea since you will be
constantly loading the program over and over which will thrash the IO
channel on your server. ISAPI would be better. The "separate code units"
that you reference .. if you mean .pas files, I never do that. I just make
them functions within the ISAPI. Because ISAPI is a little funky, you would
have to be creating objects (the connections and query objects) in code. I
find it easier to just drop them on the webmodule as I believe it was
intended. I am sure other wont agree but it works for me and I never have
memory leaks or other problems. ISAPI's can be rather large with no problems
since the OS does a better job of managing the memory that I do by trying to
segment my programs and I find that despite the ablity to create "reusable
code", I have actually found that every "resuable" bit, somehow always seems
to require just a little bit of a different nuance than when it was last
used. Thats why I dont create extra datamodules as I think you are inquiring
about.
You will need to maintain state for each client in the ISAPI.
 

Re:Best way to have more than one unit for webbroker CGI / Isapi

Peter,
Keep in mind that in an ISAPI application there is no global instance of
WebModule (despite the WebModule1 variable). Therefore the following code
will always fail:
WebModule1.adoInvoices.Open.
Within the WebModule use "Self". For code in other units, you have to pass
the WebModule (or the dataset) as a parameter, like:
unit Invoices;
uses WebModuleUnit;
function GetInvoices(AWebModule: TWebModule1): string;
begin
Result := '';
with AWebModule.adoInvoices do
begin
Open;
while not Eof do
begin
Result := Result + //....do whatever here...
end
Close;
end;
end;
 

Re:Best way to have more than one unit for webbroker CGI / Isapi

Thank you for the answers.
It makes a lot easier now to decide which way to go....
Kind regards,
Peter.
"Marco Sella" <XXXX@XXXXX.COM>schreef in bericht
Quote
Peter,

Keep in mind that in an ISAPI application there is no global instance of
WebModule (despite the WebModule1 variable). Therefore the following code
will always fail:
WebModule1.adoInvoices.Open.

Within the WebModule use "Self". For code in other units, you have to pass
the WebModule (or the dataset) as a parameter, like:

unit Invoices;

uses WebModuleUnit;

function GetInvoices(AWebModule: TWebModule1): string;
begin
Result := '';
with AWebModule.adoInvoices do
begin
Open;
while not Eof do
begin
Result := Result + //....do whatever here...
end
Close;
end;
end;


 

Re:Best way to have more than one unit for webbroker CGI / Isapi

also, check out www.matlus.com for some other helpful guidance.