Recent

Author Topic: Status of toolkit for ExtPascal  (Read 97600 times)

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #30 on: January 06, 2010, 01:22:08 pm »
In addition to that, ExtPascal provide CGI gateway mechanism. This gateway is a lightweight CGI application that acts as the loader/router of the FCGI application. This way, FCGI application doesn't need to run all the time (to save resources, etc). ExtPascal FCGI application is able to shutdown itself after some period time of idle.
That is very interesting to me !!! It seems like the web server I use (boa) does not support FastCGI. As this is not a "high traffic" application, but FCGI is needed just to allow for a permanently running background application, I suppose this really is doable and the way to go. Thanks a lot for that helpful hint !
You don't need to question more about TTimer or interactive debugging using ExtPascal's FCGI. It already does that using multithreading approach.
For more detail information, please read ExtPascal's wiki. :)
On my way.... :) I've still some doubts about the TTimer stuff, as I assume the LCL TTimer implementation uses some GUI binding for creating an event. I'll test this ASAP....

Thanks again-
-Michael
« Last Edit: January 06, 2010, 01:27:30 pm by mschnell »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #31 on: January 06, 2010, 04:22:32 pm »
Of course the CGI-application would avoid any binding to visual LCL components. But having a simple switch that - using supposedly very similar {$ifdefs as are distinguishing between design and compile state right now  - allows for either creating a CGI executable or a LCL enabled stand alone application would be really nice to have and seems to be doable (I'll take a look once I got the package running completely).

No, that makes no sense. The best you can do is create a "standalone" app that has an embedded Web server - see the ExtPascal site for doing this. This might have some application although I think it's fairly limited since you would still need to distribute the entire Ext JS package of JS controls with your app and the app would still need to be run in a browser.

VCL/LCL are too different from Ext JS and so I explicitly decided to avoid any runtime dependency on or compatibility with LCL. Here's a simple example of the problem you would have trying to "map" LCL to ExtPascal. The TExtFormLabel can probably be thought of as analogous to the VCL/LCL TLabel, but only in a crude way. TExtFormLabel has an Html property that has no analog in TLabel. You can set the Html property not only to use an HTML fragment for rich text (bolding, etc.), but also to display an image (<img src="mypic.jpg" />). How would you reproduce this with TLabel? You probably wouldn't and instead you would just lose this property altogether. With VCL/LCL you would use a TImage, which encodes the image in the .lfm file and streams it in at runtime - with HTML you need to have the image in an external file, either created in advance or created on the fly.

That's probably one of the biggest problems with the VCL/LCL/CLX approach - you end up deracinating the native widgetset, eliminating much of what is interesting and novel about it.

Note that you could develop both a desktop app and Web app that share quite a bit of code if you seperate the UI from everything else. You would then design two different UI's, one with VCL/LCL, one with ExtPascal. My toolkit's converter can even help with this if you have an existing VCL/LCL app and you want to start with the same form layout in the Web app. Of course, this raises the question of whether a Web app should look and behave like a desktop app. In some case, it might make sense but for other types of Web apps that probably wouldn't work out very well. But that's a different topic.

Also, if you look at the Gecko SDK port for Lazarus, it's possible you could create an embedded-server ExtPascal app that also eliminates the need to run the app in a browser, per se. Instead, you would run it in a TGeckoBrowser control, which fully supports JS, etc. This might provide more control over the app and could include some desktop functionality along with the "Web" app.

http://wiki.lazarus.freepascal.org/GeckoPort

Thanks.

-Phil

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #32 on: January 06, 2010, 04:47:25 pm »
No, that makes no sense.
Sorry, I did not seem to have been able to make myself clear here. What I want to do is to create an application that does "something" and has a user-interface. Same is an "embedded" thingy and the user interface is accessed only rarely, while usually the application does it's work "in the background" (using Network, serial interfaces etc.) This can be run and debugged in the normal way using Lazarus.

Now I want to make this "server based" (in fact not because I need it that way, but because with some instances of usage, the CPU the program is running on is an embedded device that does not has any user interface hardware and I want to access it in an as "standard" way as possible, thus with a browser.

To do this, I'd like to set an optional switch when creating the executable and now can install same as a cgi.

Of course I do know that for allowing this, the user interface only can define "controls" that exist (in a compatible way) as well as standard (LCL) components as as web-controls (via Extp, ExtPascal, and ExtJS).

Regarding how to do this, I'm reading your post. I might try to "ifdef" all calls to extp somehow. But at first I need to have a running extPascal example at all....

-Michael
« Last Edit: January 06, 2010, 04:52:22 pm by mschnell »

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #33 on: January 06, 2010, 04:58:37 pm »
Did you or did you not compile and run ExtToPascal.dpr?
I was able to compile ExtToPascal.dpr (and with a slight modification) CGIHateway, too).

I ran ExtToPascal on Extjs 3.1.0, which is the "current" download. it created 13 units (rather than 19 as described in the docs for 3.0.0).

Now I tried to compile the extp "hello" example and got the error:
Identifyer not found TExtHistory" in ext.pas.

Now I'm trying to find Extjs 3.0.0, to see if same works....

-Michael

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #34 on: January 06, 2010, 05:02:35 pm »
You can use Ext JS 3.1.0 if you use the pre-generated Ext.pas, etc. units from SVN. The next release of ExtPascal (0.9.8) will include these so you don't have to build them anymore - in fact, you can't build all of them anymore because Ext JS has dropped docs for some of them for some reason.

Thanks.

-Phil

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #35 on: January 06, 2010, 05:40:58 pm »
Hi Phil,
I got the Hello example it compiled using extjs 3.0.0 :) :) :)

If you think it makes sense to use 3.1.0, please do upload the files somewhere, as I don't want to install svn for that purpose (firewall/proxy problems etc.  But maybe the svn has a browser interface to d/l files ? )

So lets see where I can get to.
(First trying to find/use the built-in web server then trying to use the CGIGateway with the boa webserver.....)

Thanks a lot for the packet and for all help you provided up til now. :)
-Michael


Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #36 on: January 06, 2010, 06:20:52 pm »

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #37 on: January 07, 2010, 12:20:25 pm »
First trying to find/use the built-in web server ....
Ooops !

I easily found how to enable this by setting -dWebServer, but now it needs IdCustomHTTPServer.

So I seem to need to install Indy. :o

Is this possible with Lazarus/Linux ? How ? Which version do I need (I found they are quite different) ?

Thanks,
-Michael
« Last Edit: January 07, 2010, 12:36:58 pm by mschnell »

Phil

  • Hero Member
  • *****
  • Posts: 2737

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #39 on: January 07, 2010, 04:22:05 pm »
Thanks,
I did see this, but as the Lazarus docs say that with Indy 9 hardly anything is working in Linux while with Indy 10 nothing works in Linux, I'd like to ask if you did try this.

Thanks again,
-Michael

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #40 on: January 07, 2010, 04:33:52 pm »
I don't use Linux so I don't know if I can help you much there.

I have used Indy 10.1.1 successfully on OS X with both ExtPascal and the Web Service Toolkit, though.

Have _you_ actually tried to use Indy with ExtPascal? The Laz docs are often out of date.

Thanks.

-Phil

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #41 on: January 07, 2010, 05:01:34 pm »
I found an indi port for Lazarus/linux here:

http://www.indyproject.org/Sockets/fpc/index.en.html

I installed the files and in fact I can compile and run the program with webserver enabled.

If I use a bowser to connect to the port, I in fact get a result from the program: the browser shopws an empty page with this html-code:


Code: [Select]
<?xml version=1.0?><!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN">
<html xmlns=http://www.w3org/1999/xthml>
<head>
<title>MyApp</title>
<meta http-equiv="content-type" content="charset=utf-8">
<link rel=stylesheet href="/ext/resources/css/ext-all.css" />
<script src="/ext/adapter/ext/ext-base.js"></script>
<script src="/ext/ext-all.js"></script>
</head>
<script>
Ext.onReady(function(){Ext.BLANK_IMAGE_URL="/ext/resources/images/default/s.gif";TextMetrics=Ext.util.TextMetrics.createInstance("body");function AjaxError(m){Ext.Msg.show({title:"Ajax Error",msg:m,icon:Ext.Msg.ERROR,buttons:Ext.Msg.OK});};function AjaxSuccess(response){try{eval(response.responseText);}catch(err){AjaxError(err.message+"<br/>Use DebugJS define to enhance debugging<br/>"+response.responseText);}};function AjaxFailure(){AjaxError("Server unavailable, try later.");};Download=Ext.DomHelper.append(document.body,{tag:"iframe",cls:"x-hidden"}); OE=new Ext.Button({id:"ExtButton1",tooltipType:"title",x:152,height:38,y:192,width:101,text:"Click Me"}); O0=new Ext.Window({id:"MainWindow",layout:"absolute",height:334,width:408,onEsc:function(){},title:"Hello",items:[OE]});O0.nm="O0";OE.nm="OE";OE.on("click",function(){return Ext.Ajax.request({url:"/MainWindow_ExtButton1Click",params:"Ajax=1&",success:AjaxSuccess,failure:AjaxFailure});});O0.show("");});
</script>
<body><div id=body></div><noscript>This web application requires JavaScript enabled</noscript></body>
</html>

So the HTTP server seems to work, but something in the application goes wrong.

In the Browser's error console I see some errors. e,g,;

Error: The stylesheet http://127.0.0.1:8088/ext/resources/css/ext-all.css was not loaded because its MIME type, "text/html", is not "text/css".
Source File: http://127.0.0.1:8088/
Line: 0

Error: missing ; before statement
Source File: http://127.0.0.1:8088/ext/ext-all.js
Line: 1, Column: 21
Source Code:
<?xml version=1.0?><!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN">

Error: Ext is not defined
Source File: http://127.0.0.1:8088/
Line: 11

Supposedly the internal http server does not find the folders /ext and /text.

Any more ideas ?

Moreover:

I can start the application from the command line, but I can't seem to start it from the Lazarus IDE to debug it.

I can do ine step with F7 and get to "begin" in myproject.lpr. But 'the next F7 does not do anything. If I try to run it with F9 after setting some Breakpoint, same is not reached. And I don't seem to be able to access it with the browser, even though the IDE claims that the program is still running, and pushing the red stop button produces "execution stopped".

What did I do wrong ?

Thanks,
-Michael
« Last Edit: January 07, 2010, 05:13:50 pm by mschnell »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #42 on: January 07, 2010, 05:09:32 pm »
Try following the wiki steps and get it working that way first.

Check your browser's error console for JS errors.

Thanks.

-Phil

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #43 on: January 07, 2010, 05:22:43 pm »
Check your browser's error console for JS errors.
Already did this. You were too fast :) ! I was editing my previous message at the same time you responded. Please take a look above.

-Michael
« Last Edit: January 07, 2010, 05:33:23 pm by mschnell »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #44 on: January 07, 2010, 05:29:04 pm »
Did you follow the wiki instructions and copy the Ext JS folder below your executable's folder?

Thanks.

-Phil

 

TinyPortal © 2005-2018