fcl-web impossible to use with FPC (no Lazarus)
lazarus / 38-Networking and Web Programming
----------------------------------------------------------------------
hinst · 2013-10-27 20:00
So it is impossible to use fcl-web if I don't have Lazarus installed?
Am I right? Because TFPWebModule requires a resource file attached to
it to load OnRequest handler from it? Just one method? I believe it
works this way to maintain Delphi compatibility....... I am working on
an application which is meant to work on Linux server, so I can't have
Lazarus installed on it. And I can't build this application on my PC
and then deploy it to server because I use Windows
Whenever I try to launch my application I get the following exception
message: Failed to initialize component class "THandlerModule": No
streaming method available. Of course it can't load component from
resource because no resource is attached
----------------------------------------------------------------------
Leledumbo · 2013-10-28 08:56
QuoteSo it is impossible to use fcl-web if I don't have Lazarus
installed? Am I right?No, you're wrong. After all, fcl-web is
developed separately from Lazarus (it's part of FCL, not LCL) and it
borns prior to Lazarus. How could it depend on something that borns
later?
QuoteBecause TFPWebModule requires a resource file attached to it to
load OnRequest handler from it? Just one method?This is RAD extension
to fcl-web by Lazarus, you can perfectly code your web modules without
the form designer.
QuoteI am working on an application which is meant to work on Linux
server, so I can't have Lazarus installed on it. And I can't build
this application on my PC and then deploy it to server because I use
WindowsEither use Linux, or cross compile from your Windows.
QuoteWhenever I try to launch my application I get the following
exception message: Failed to initialize component class
"THandlerModule": No streaming method available. Of course it can't
load component from resource because no resource is attachedIf you
already use the one created from fpweb wizard, it already depends on
the RAD extension. I'll show you a pure fcl-web one that you can build
without Lazarus when I get home.
----------------------------------------------------------------------
hinst · 2013-10-29 19:24
Quote from: Leledumbo on October 28, 2013, 09:56:06 amEither use
Linux, or cross compile from your Windows.
I have no problem with compilation if it does not require Lazarus
Quote from: Leledumbo on October 28, 2013, 09:56:06 amI'll show you a
pure fcl-web one that you can build without Lazarus when I get home.
Please do it if U can plz
It would be nice if wiki had information on how to use fcl-web
separately from Lazarus; I searched but could not find
----------------------------------------------------------------------
Leledumbo · 2013-10-30 10:06
Please remind me through PM, I lost this thread yesterday night.
----------------------------------------------------------------------
Graeme · 2013-10-30 11:42
Quote from: hinst on October 27, 2013, 09:00:59 pmSo it is impossible
to use fcl-web if I don't have Lazarus installed?
No it is definitely possible, but maybe not so obvious... I struggled
too, due to the streaming part, but Michael van Canneyt talked me
through the process.
For example, here is what I have done for a CGI (client) application:
* Use fpcgi.pp as the Application class - though it isn't required,
but it makes things easier.
* The program unit has this code
Code: [Select] Application.Title := gM2Browser.Caption;
Application.Email := 'support@mastermaths.co.za';
Application.DefaultModuleName := 'login'; { if no module name is
specified in URL, who handles that request. }
Application.PreferModuleName := True; { now web actions are not the
default any more }
Application.Initialize;
Application.Run;
* Create new units which define a web module class descending from
TFPWebModule (found in the fpweb.pp unit. Other units in the uses
clause are HTTPDefs and fpHTTP
* In the web module unit, add an initialization section as follows...
TLoginModule is the TFPWebModule descendant class I created.
Code: [Select]
initialization
RegisterHTTPModule('login', TLoginModule, True);
NOTE: Very important is the last parameter in the RegisterHTTPModule()
call! The "True" values means you want to skip the streaming support -
which means you don't require Lazarus!!!
* In the web module class, NEVER override the Create() constructor,
ALWAYS override the CreateNew() constructor instead. I can't remember
the reason why - I don't have access to Michael's email to me.
* Now override the web module's DoOnRequest() method and implement
your web module as you see fit. Set AHandled := True if you don't want
the web module to process Web Actions etc.
That's it for a CGI web modules client application.
Further reading on the following is useful too..
Code: [Select] Application.DefaultModuleName := 'login'; { if no
module name is specified in URL, who handles that request. }
Application.PreferModuleName := True; { now web actions are not the
default any more }
Hope you found this useful.
----------------------------------------------------------------------
hinst · 2013-10-30 14:16
Hmmm thanks a lot; I hope I will manage to get it to work now
----------------------------------------------------------------------
Leledumbo · 2013-10-30 15:05
Quote* In the web module class, NEVER override the Create()
constructor, ALWAYS override the CreateNew() constructor instead. I
can't remember the reason why - I don't have access to Michael's email
to me.Same reason with TForm.
@hinst: attached is the fcl-web example without lcl, using embedded
server
----------------------------------------------------------------------
hinst · 2013-10-31 18:26
Looks like I discovered a bug
@Leledumbo: I modified your project a bit; like this:
Code: [Select] AResponse.Content :=
'
' +
'Hello World!
' +
'"' + aRequest.Host + '"' +
''
;
And guess what: fpc does not detect host while my browser (Firefox)
puts 127.0.0.1:2000 in host field. I actually spent some (a lot of)
time trying to figure out why apache wouldn't proxy Host header to my
fpc server app before I realized that fpc is to blame, not apache lol
I planned to use Host HTTP request field to generate links to other
pages of my web app. Well, it is possible to live with it; for
example, one can store host value elsewhere to generate http links on
web pages.
So... Am I right? is this a but or a feature? I wonder if it got fixed
in latest FPC 2.7 (I'm using 2.6.3)
P.S.: I'm not complaining, just asking. I am actually glad that it
works at all;
P.P.S.: Just checked: no, in FPC 2.7 aRequest.Host is also an empty
string. I wonder if there is a workaround
----------------------------------------------------------------------
Leledumbo · 2013-11-01 06:39
QuoteP.P.S.: Just checked: no, in FPC 2.7 aRequest.Host is also an
empty string. I wonder if there is a workaroundI think you know where
to report, bugtracker link is on the left menu. You can always see how
and when the field is filled anyway, you have the full source.
----------------------------------------------------------------------
BeniBela · 2013-11-01 19:42
Quote from: hinst on October 31, 2013, 07:26:46 pm
P.S.: I'm not complaining, just asking. I am actually glad that it
works at all;
Why not? This is a good place for it
And I'm going to complain.
So it seems fcl-web does not work with POST parameters, and it does
not work with GET parameters.
So how can it ever be used for anything?
Did anyone ever test this crap?
----------------------------------------------------------------------
Leledumbo · 2013-11-02 04:15
QuoteSo it seems fcl-web does not work with POST parameters, and it
does not work with GET parameters.
So how can it ever be used for anything?It DOES work with both, even
with all other methods.
QuoteDid anyone ever test this crap?You're starting to get annoying,
your tools are not the best as well, good only for quick coding
project. fcl-web works for much bigger and greater web application
area.
----------------------------------------------------------------------
BeniBela · 2013-11-02 09:59
Quote from: Leledumbo on November 02, 2013, 05:15:19 am
It DOES work with both, even with all other methods.
Now they work with POST, because I have fixed the bug.
Quote from: Leledumbo on November 02, 2013, 05:15:19 amYou're starting
to get annoying, your tools are not the best as well, good only for
quick coding project. fcl-web works for much bigger and greater web
application area.
This has nothing to do with my tools (despite their name they have
become a replacement for fcl-xml, not fcl-web)
----------------------------------------------------------------------
Leledumbo · 2013-11-02 13:13
QuoteNow they work with POST, because I have fixed the bug.And what
your point of saying this? Nothing can ever be made working
automatically, somebody has got to implement it. If it's broken,
somebody has to fix it. Do your tools and any other libraries in the
world has NO bug and have ALL their features working on their first
release? Or second? Or third?
----------------------------------------------------------------------
BeniBela · 2013-11-02 14:05
Quote from: Leledumbo on November 02, 2013, 02:13:26 pm
And what your point of saying this?
That almost everytime I have used a non-trivial function in the
rtl/lcl, I have spend more time debugging the rtl/lcl than I would
have needed to reimplement it from scratch.
And that is very annoying
Quote from: Leledumbo on November 02, 2013, 02:13:26 pmNothing can
ever be made working automatically, somebody has got to implement it.
If it's broken, somebody has to fix it.
It also does not break automatically.
If it is broken, somebody is the idiot who broke it
Quote from: Leledumbo on November 02, 2013, 02:13:26 pmDo your tools
and any other libraries in the world has NO bug and have ALL their
features working on their first release? Or second? Or third?
The other libraries only have a tenth of the bugs fpc has
And parsing parameters is not a random feature, it is the main
function of a web framework
----------------------------------------------------------------------
Leledumbo · 2013-11-02 15:33
QuoteThat almost everytime I have used a non-trivial function in the
rtl/lcl, I have spend more time debugging the rtl/lcl than I would
have needed to reimplement it from scratch.You shouldn't be in the
open source community if you're not willing to do any contribution.
QuoteIt also does not break automatically.
If it is broken, somebody is the idiot who broke itI wouldn't say that
for a person who spend his spare time writing libraries that could get
me paid while he himself doesn't get anything.
QuoteThe other libraries only have a tenth of the bugs fpc hasYou
must have never used any big libraries with community only support.
wxWidgets currently has >2000 active bugs, gtk+ has >3000, GCC has
nearly 8000 (>7800), FPC never has >1000 (not even 500 AFAIR) at the
same time.
QuoteAnd parsing parameters is not a random feature, it is the main
function of a web frameworkAnd it could get wrong, everybody makes
mistake, even the most experienced coder can make trivial mistake.
----------------------------------------------------------------------
BeniBela · 2013-11-02 17:07
Quote from: Leledumbo on November 02, 2013, 04:33:07 pm
I wouldn't say that for a person who spend his spare time writing
libraries that could get me paid while he himself doesn't get
anything.
If the library does not work, it does not help you to get paid.
In fact, you are losing money, because you wasted time bothering with
the library.
Quote from: Leledumbo on November 02, 2013, 04:33:07 pmYou must have
never used any big libraries with community only support.
wxWidgets currently has >2000 active bugs, gtk+ has >3000, GCC has
nearly 8000 (>7800), FPC never has >1000 (not even 500 AFAIR) at the
same time.
That just shows that barely noone is using fpc and the bugs are
therefore not reported.
It's get more realistic, if you count the bugs you find while using
it. That's for me: bugs in fpc: 33 bugs in gcc: 0
Quote from: Leledumbo on November 02, 2013, 04:33:07 pmAnd it could
get wrong, everybody makes mistake, even the most experienced coder
can make trivial mistake.
That's exactly why I complained about the lack of testing, not the
mistakes
----------------------------------------------------------------------
Leledumbo · 2013-11-02 17:20
QuoteIf the library does not work, it does not help you to get paid.
In fact, you are losing money, because you wasted time bothering with
the library.Well it does work (OK, thanks to you). Even when there are
bugs, I don't lose any money. I'm paid to develop, and debugging is
part of the development, including bug reporting and wait for a fix
(or do the fix myself and send patches back).
QuoteThat just shows that barely noone is using fpc and the bugs are
therefore not reported.Yeah, in your interpretation. 169 projects in
wiki ONLY means barely no one.
QuoteIt's get more realistic, if you count the bugs you find while
using it. That's for me: bugs in fpc: 33 bugs in gcc: 0You're lucky
to have never met gcc crashes while compiling certain code, or worse,
generate wrong code. Maybe you haven't used it extensive enough as I
did. And remember, gcc only covers compiler and standard libraries,
fpc covers compilers, ide, utilities and packages.
QuoteThat's exactly why I complained about the lack of testing, not
the mistakesThen help writing test cases, don't just complain. Well,
if you wish to contribute. It's free software after all.