* * *

Author Topic: The Brooks Framework  (Read 3269 times)

Zoran

  • Hero Member
  • *****
  • Posts: 1246
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: The Brooks Framework
« Reply #15 on: May 28, 2018, 07:36:38 pm »
There are also Michael Van Canneyt's articles on this link: https://www.freepascal.org/~michael/articles/

There you can find articles named web1, web2, and webserver. Although a bit outdated, these are well written tutorials, so don't miss them if you are starting with fcl-web!

dbannon

  • Sr. Member
  • ****
  • Posts: 302
Re: The Brooks Framework
« Reply #16 on: May 29, 2018, 04:15:18 am »
Quote
Application.LegacyRouting := True;

No, that does not work. 'Application' is, apparently, out of scope.

So, in this example, I have chosen to make a new project, selected something like "Web Server" from the new project list. And it seems to be based on TFPWebModule1. I don't understand why there is no underlying Application object but seems no.

TFPWebModule1 does not seem to have a property 'LegacyRouting either.

So, I added Forms to uses. But then Application does not have a property called LegacyRouting nor anything similar.

I, personally, don't really need the webserver anyway, it just seemed a good idea to work through Leledumbo tutorial. And its the first and very simple example.

Davo
« Last Edit: May 29, 2018, 04:41:19 am by dbannon »
Lazarus 1.8, Linux (and reluctantly Win10, OSX)

nummer8

  • New member
  • *
  • Posts: 40
Re: The Brooks Framework
« Reply #17 on: May 29, 2018, 08:30:55 am »
Davo,

Here a fully working Hello World project as a standalone webserver.
Check the httpproject1.lpr file for the LegacyRouting parameter.
Point your browser to http://Localhost:8080
Port settings are also changeable in the same file.
Forms are not used in fp-web applications.
If you want to add something use a webmodule. (File -> New...)
 
Jos
 
edit: updated the project, added the missing file
« Last Edit: May 30, 2018, 08:15:12 am by nummer8 »

Leledumbo

  • Hero Member
  • *****
  • Posts: 7953
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: The Brooks Framework
« Reply #18 on: May 29, 2018, 10:26:49 pm »
Quote
Application.LegacyRouting := True;

No, that does not work. 'Application' is, apparently, out of scope.

So, in this example, I have chosen to make a new project, selected something like "Web Server" from the new project list. And it seems to be based on TFPWebModule1. I don't understand why there is no underlying Application object but seems no.

TFPWebModule1 does not seem to have a property 'LegacyRouting either.

So, I added Forms to uses. But then Application does not have a property called LegacyRouting nor anything similar.

I, personally, don't really need the webserver anyway, it just seemed a good idea to work through Leledumbo tutorial. And its the first and very simple example.

Davo
It's a global variable (available from any of the server unit: fpcgi, fpfcgi or fphttpapp), access it in the program source (.lpr), not the module units (.pas / .pp), even if it's possible I don't consider it a good practice.

dbannon

  • Sr. Member
  • ****
  • Posts: 302
Re: The Brooks Framework
« Reply #19 on: May 30, 2018, 05:22:52 am »
Here a fully working Hello World project as a standalone webserver.
Check the httpproject1.lpr file for the LegacyRouting parameter......

Thanks Joz, yep, I put that line in the lpr file and it compiled and worked as expected. Thanks.
By the way, your zip did not include the .lpi file, needed to build it. But easy to paste the relevant line, "Application.LegacyRouting := True; " into the .lpr file of my (absolute minimal) project and, as you said, it does work.

Thanks !
Lazarus 1.8, Linux (and reluctantly Win10, OSX)

dbannon

  • Sr. Member
  • ****
  • Posts: 302
Re: The Brooks Framework
« Reply #20 on: May 30, 2018, 05:34:26 am »
It's a global variable (available from any of the server unit: fpcgi, fpfcgi or fphttpapp), access it in the program source (.lpr), not the module units (.pas / .pp), even if it's possible I don't consider it a good practice.

Sorry Leledumbo, can you please clarify, do you mean you consider using this switch at all to be bad practice or is the bad practice  just using it in a .pas or .pp file ?

When I used it in my .lpr file, things started to work.

Does that  switch indicates something is wrong ?  I'm guessing fcl-web uses an 'out of date' model, replaced in Lazarus, when we request "LegacyRouting" - is this a viable, long term solution ? if its a good thing, should that switch be patched into the Lazarus code base ?

Davo
Lazarus 1.8, Linux (and reluctantly Win10, OSX)

nummer8

  • New member
  • *
  • Posts: 40
Re: The Brooks Framework
« Reply #21 on: May 30, 2018, 08:29:42 am »
Davo,

The switch is not an indication that there is something wrong.
It is just a switch to make it possible to choose from two different routing systems for your project.
Just set it in the program source (and no where else).
To get the other examples running make the same change to the program source.

Jos
 

Leledumbo

  • Hero Member
  • *****
  • Posts: 7953
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: The Brooks Framework
« Reply #22 on: May 31, 2018, 05:45:55 am »
Sorry Leledumbo, can you please clarify, do you mean you consider using this switch at all to be bad practice or is the bad practice  just using it in a .pas or .pp file ?
The latter.
Does that  switch indicates something is wrong ?  I'm guessing fcl-web uses an 'out of date' model, replaced in Lazarus, when we request "LegacyRouting" - is this a viable, long term solution ? if its a good thing, should that switch be patched into the Lazarus code base ?
No, nothing wrong. It's just the old way of routing is unnecessarily complex and is tailored too much for RAD use. Lazarus doesn't alter anything to fcl-web (apart from providing a wizard to create fpWeb project easily), it's fcl-web (fpWeb actually) itself that is evolving. This should be the long term solution, hence the LegacyRouting property is off by default, to make further new usage uses the new routing immediately instead of maintaining backward compatibility with old projects (which is also a one liner change).

dbannon

  • Sr. Member
  • ****
  • Posts: 302
Re: The Brooks Framework
« Reply #23 on: May 31, 2018, 03:03:03 pm »
OK, thanks heaps folks for the help you have given me with getting this going. I will be taking my project into this space, one way or another, in the not to distant future.

And as I mentioned, hope I can contribute some documentation along the way.

Davo
Lazarus 1.8, Linux (and reluctantly Win10, OSX)

Leledumbo

  • Hero Member
  • *****
  • Posts: 7953
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: The Brooks Framework
« Reply #24 on: May 31, 2018, 09:26:23 pm »
And as I mentioned, hope I can contribute some documentation along the way.
Pull requests to my tutorial is acceptable :)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus