El 22/02/2014 23:02, silvioprog escribió:
2014-02-22 15:11 GMT-03:00 Giuseppe Luigi <[email protected] <mailto:[email protected]>>:

    Sorry for late reply, too busy :(

    What approach you follow to build your sites? Jtemplate? Use brook
    just as restful server?

I use it according the project. In several projects, I use only GET/POST, JTemplate and HTML. But there are also projects that I use GET/POST/PUT/DELETE, RESTful and some JS library, such as JTable, for example.

Maybe I will do some testing with JTemplate, using Anderson(*) videos as helpers.

(*) http://www.youtube.com/watch?v=Y2ZozfS1aSg

    Im still just trying to figure on my mind how to "deploy" my idea
    to Brook development. My web development skills are mainly based
    working over CMS

    Regards.

Some time ago, I have developed projects with CMS like Joomla and WordPress. Yes, it is practical, but they don't give me the same power to manipulate the content that will displayed on the screen. But I've thought about creating a CMS using Brook.

Well, mainly my web development projects are based on corporative websites or eCommerce, not custom-made implementations. Here a CMS is the best option. Now I want to build a Web App. Are different kind of projects :P


ps. The Brook 3.0 is being released with new ideas of João Morais (https://github.com/jcmoraisjr). It will be completely different from Brook 2.6.4. In the new Brook, you can receive objets instead JSONs, see a small comparison;

form.html:

<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Person</title>
</head>
<body>
<form action="http://localhost/cgi-bin/cgi1.bf"; method="post">
<input type="text" name="id" />
<input type="text" name="name" />
<input type="submit" />
</form>
</body>
</html>

Brook 2.6.4:

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  BrookAction;

type
  TMyAction = class(TBrookAction)
  public
    procedure Post; override;
  end;

implementation

procedure TMyAction.Post;
begin
  // where's validation?
Write('ID: %d, Name: %s', [Fields['id'].AsInt64, Fields['name'].AsString]); // where's reuse?
  // where's persistence?
end;

initialization
  TMyAction.Register('/person');

end.

Brook 3.0:

unit person;

{$mode objfpc}{$H+}

interface

uses
  SysUtils;

type
  EPerson = class(Exception);

  { TPerson }

  TPerson = class
  private
    FId: Int64;
    FName: string;
  public
    procedure Validate;
    procedure Save;
  published
    property Id: Int64 read FId write FId;
    property Name: string read FName write FName;
  end;

implementation

{ TPerson }

procedure TPerson.Validate;
begin
  if Trim(FName) = '' then
    raise EPerson.Create('Name must not be empty.');
end;

procedure TPerson.Save;
begin
// implement your persistence here, using a framework like dpof: https://github.com/silvioprog/dopf
end;

end.

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  BrookAction, person;

type
  TMyAction = class(specialize TBrookEntityAction<TPerson>)
  public
    procedure Post; override;
  end;

implementation

procedure TMyAction.Post;
begin
  Entity.Validate; // Yes, my own validation!
Write('ID: %d, Name: %s', [Entity.Id, Entity.Name]); // Yes, I'm reusing my object! Entity.Save; // I love it, my validation using OPF (like https://github.com/jcmoraisjr/jcore or https://github.com/silvioprog/dopf) of DAO!
end;

initialization
  TMyAction.Register('/person');

end.



Looks interesting. Are Brook 3 in your github too? When is planned to release?

Regards.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to