CGI or Web based application lazarus / 13-General ---------------------------------------------------------------------- Fossy · 2008-02-26 16:56 Hello friends: Exists now components for make Web based applications?. Otherwise, exists any CGI component?. I have searched in forum, but I only have see one post of year 2005 saying the develop of Web based components... Thanks!! ---------------------------------------------------------------------- OnixJr · 2008-02-26 20:03 See Powtils at http://wiki.lazarus.freepascal.org/Powtils.. See too testcgi on demos directory of freepascal... Júnior ---------------------------------------------------------------------- chrnobel · 2008-02-28 09:36 Quote from: "Fossy" Exists now components for make Web based applications?. Otherwise, exists any CGI component?. So definitely Powtils: http://z505.com/powtils/idx.shtml Works like a charm, and is really fast - combine it with MySQL via Zeos, and all other active servers seems like a bad joke. /Christian ---------------------------------------------------------------------- Ahi · 2008-03-10 14:19 Hi all! There are units: cgiModules cgiapp already included in Free Pascal / Lazarus. However, they do not work (as distributed), due to some bugs. If I get them fixed, how should I send in the fixed versions ? About bug fixing style: I can see, that  unit cgiModules ends like this: (some of my fixes already applied, namely commented out the auto-creation of the Application variable(object instance). Initialization  // Auto-initialization REMOVED: 2008-03-10 AHi   // Application:=TModuledCGIApplication.Create(Nil);   // RegisterInitComponentHandler(TComponent,@InitResourceComponent); Finalization   // Application.Free; end. The reason I commented them out was that also the main program/project file, for which the skeleton is also auto-created  (MyAppname.lpr), also creates an instance of Application variable, like this: begin   Application:=TMyApplication.Create(nil);   RegisterInitComponentHandler(TComponent,@InitResourceComponent);   Application.Initialize;     CloseDebugOutput;     Application.CreateForm(TCGIDatamodule1, CGIDatamodule1);   TMyApplication(Application).Run2;   Application.Free; end. When both this code and the (original) finalization section of cgiModules try to free the  Application instance, the 2nd freeing of course causes an access violation. Also, since I could not get a breakpoint  set  into the "run" method, I decided to replace it with my own, but since the original is not virtual, I had no other choise but  to name that "run2". If just naming the repalcement "Run" then the original will be called, not my version. How to best fix this? If the goal is to be 100% delphi compatible, then it should be done as in Delphi. Otherwise, I prefer not auto-creating the Application instance in the unit cgiModules, because creating it in the MyAppName.lpr lets the application programmer to derive his/her own class from TModuledCGIApplication, if necessary. An elegant solution of this dilemma would be to do something like this: type   TApplicationClassType = class of TModuledCGIApplication; var   ApplicationClassType : TApplicationClassType  = TModuledCGIApplication; and then auto-creating it as the type defined in ApplicationClassType. However, actually implementing this seems either impossible, or otherwise it mandates creating an extra unit, and putting there something like TModuledCGIApplicationBase = class(...) (all new methods should be virtual abstract methods). and then deriving TModuledCGIApplication fromTModuledCGIApplicationBase. Otherwise, if they are defined in the same unit, and there is an initialization section, you have no chance to change the type defined in ApplicationClassType before the Application instance already gets created as the default type. I'd like comments from the authors of Lazarus, what do you consider best to achieve both Delphi compatibility and the possibility for the application developer to derive his/her own type from TModuledCGIApplication. --- There are other problems, too: 1. the OnCGIRequest method (eventhandler) is originally shown in the object inspector of the IDE. But if I save the project, close it, then reload, Lazarus claims that such an (event) property doesn't exist. It seems to me as if Lazarus first recognizes the module as a cgi module, but  after closing and reloading the project, suddenly refuses to recognize the module as a cgi module, but instead treats it as a normal datamodule, and so complains about a property that doesn't exist. So I solved this problem by not setting the event from the IDE, but instead assign it programatically, like this: constructor TCGIDatamodule1.CreateNew(AOwner: TComponent; Crea]"]>Blockedde: Integer); begin   inherited CreateNew(AOwner, Crea]"]>Blockedde);     // The only one of these, that actually gets called !   // debugln('My_3 TCGIDatamodule1.CreateNew() called from ',AOwner.CLassName);   OnCGIRequest := CGIDatamodule1CGIRequest; end; I also tried overloading these two to try to do the same, but found out that they never get called: procedure TCGIDatamodule1.DataModuleCreate(Sender: TObject); begin // NEVER really called, why ?   OnCGIRequest := CGIDatamodule1CGIRequest;   debugln('My_1 TCGIDatamodule1.DataModuleCreate called from ',Sender.CLassName); end; constructor TCGIDatamodule1.Create(AOwner: TComponent); begin // NEVER really called, why ?   inherited Create(AOwner);   OnCGIRequest := CGIDatamodule1CGIRequest;   debugln('My_2 TCGIDatamodule1.Create() called from ',AOwner.CLassName); end; A. Hiismäki ---------------------------------------------------------------------- Fossy · 2008-03-11 11:56 Thanks thanks thanks!!!!! Thanks to all for answers, I will use Powtils . Only one question..., Can I implement a WYSIWYG editor in Powtils for load and save documents like Microsoft Word?. I need to make an web application, and one of options is create free rich documents (with backgrounds, font sizes, alignments, and more), and I would like show a WYSIWYG editor for it with open and save documents options. Thanks!! ---------------------------------------------------------------------- L505 · 2008-03-12 16:20 Quote from: "Fossy"Thanks thanks thanks!!!!! Thanks to all for answers, I will use Powtils . Only one question..., Can I implement a WYSIWYG editor in Powtils for load and save documents like Microsoft Word?. I need to make an web application, and one of options is create free rich documents (with backgrounds, font sizes, alignments, and more), and I would like show a WYSIWYG editor for it with open and save documents options. Thanks!! Do you mean like Dreamweaver? Or do you mean an online web program? ---------------------------------------------------------------------- L505 · 2008-03-12 16:47 Quote from: "Ahi"Hi all! There are units: cgiModules cgiapp already included in Free Pascal / Lazarus. However, they do not work (as distributed), due to some bugs. If I get them fixed, how should I send in the fixed versions ? About bug fixing style: I can see, that  unit cgiModules ends like this: (some of my fixes already applied, namely commented out the auto-creation of the Application variable(object instance). Initialization  // Auto-initialization REMOVED: 2008-03-10 AHi   // Application:=TModuledCGIApplication.Create(Nil);   // RegisterInitComponentHandler(TComponent,@InitResourceComponent); Finalization   // Application.Free; end. The reason I commented them out was that also the main program/project file, for which the skeleton is also auto-created  (MyAppname.lpr), also creates an instance of Application variable, like this: Commenting stuff out, instances, application variable.. what's any of this got to do with getting work done, now? Quote from: "Ahi" begin   Application:=TMyApplication.Create(nil);   RegisterInitComponentHandler(TComponent,@InitResourceComponent);   Application.Initialize;     CloseDebugOutput;     Application.CreateForm(TCGIDatamodule1, CGIDatamodule1);   TMyApplication(Application).Run2;   Application.Free; end. When both this code and the (original) finalization section of cgiModules try to free the  Application instance, the 2nd freeing of course causes an access violation. Dangling pointers, GOTO statements? Sounds like this is what programming is becoming again. Who would have thought Pascal would become like C/Assembly or BASIC programming where your GOTO statement leads you to who knows where. Just to get a simple web program running. And the alternatives out there are what.. Ruby, PHP, Python, which make things much less stressful. I can see why Modern Pascal is dying, folks.. I can see it. Quote from: "Ahi" Also, since I could not get a breakpoint  set  into the "run" method, I decided to replace it with my own, but since the original is not virtual, I had no other choise but  to name that "run2". All this breakpoint, virtual, method, and other crap.. Why is programming hard? Is this the GOTO programming of the 1990's? What, it's past year 2000. Are we coding in assembly or BASIC? Why is this so hard? What is making this so hard for us? Why are we having so many troubles? In GOTO progamming or with dangling C pointers,  we have the same problems as we do with getting a simple CGI program to run in Pascal. Is this a good thing? Quote from: "Ahi" Otherwise, I prefer not auto-creating the Application instance in the unit cgiModules, because creating it in the MyAppName.lpr lets the application programmer to derive his/her own class from TModuledCGIApplication, if necessary. What has this instance, that instance, and creating this, autocreating that, and creating that other thing got to do with getting a simple cgi program done? All this Creating here, freeing there, initializing crap there, deriving this crap here, inheriting this crap there... have you even got a simple program working? One program? I can see why modern pascal is dying.. I'm sorry but I see it. When are we going to get on with DOING WORK and stop diddling around with this nonsense that has NOTHING to do with getting the actual work done? Quote from: "Ahi" An elegant solution of this dilemma would be to do something like this: The elegant solution, is to stop the nonsense.. stop the insanity.. "GOTO PROGRAMMING OF THE 1990's" Quote from: "Ahi" type   TApplicationClassType = class of TModuledCGIApplication; var   ApplicationClassType : TApplicationClassType  = TModuledCGIApplication; and then auto-creating it as the type defined in ApplicationClassType. But, have you got any work done yet? When? When oh when? When are we going to get work done? What's all this have to do with getting the stuff done, now? I can see why modern pascal is dying... Quote from: "Ahi" However, actually implementing this seems either impossible, or otherwise it mandates creating an extra unit, and putting there something like TModuledCGIApplicationBase = class(...) (all new methods should be virtual abstract methods). and then deriving TModuledCGIApplication fromTModuledCGIApplicationBase. What the heck, though, has this got to do with getting work done? I can see why people use Perl and I realize why Pascal is dieing. Oh boy.