#1 Re: mORMot 1 » TSynDictionary FindAndCopy strange behaviour » 2019-11-11 16:41:25



Finally I found the issue was the key structure. I changed it from

   tDicInteger  = {$ifdef NOVARIANTS}integer{$else}variant{$endif};
   tDicKey =
      packed Record
        I,J : tDicInteger;


tDicKey = RawUTF8;  //I will merge I and J to obtain a unique string.

And that works as expected now. This is an acceptable workarround  for me.

I still don't know why it was not working before.

An other point was : D.Count was not equal to the number of D.Add (with each key unique) but the number of distinct I value.

#2 mORMot 1 » TSynDictionary FindAndCopy strange behaviour » 2019-11-09 21:28:01

Replies: 1


I'm facing a TSynDictionary strange behaviour :

The code below works as expected...
  P.I :=1119; P.J:=2220;
  Tuile[0].Nom := 'Toto';
  Tuile[0].Coordonnees := 'gggg';
  Tuile[1].Nom := 'Titi';
  Tuile[1].Coordonnees := 'lll';
  D.Add(P,Tuile) ;
Now, I've add a "CreateAndFillPrepare.." + While FillOne ... begin end;

  while LienTuile.FillOne do
    .....Some code....
    .....Some code....
    D.Add(P,Tuile);      //P is the last inserted
    D.FindAndCopy(P,Tuile2);  //>>>This works as expected
    D.FindAndCopy(R,Tuile2);  //>> This still works as expected for some iteration only. After some iteration, it stop to work (Tuile2 is unassigned)

  Some idea about what is wrong?

Edit: It's look like it depends on the number of keys. I will investigate more and come back with more information.
Edit2 : The more I investigate the less I understand. It's look like memory leak.
When I do this:
        D.FindAndCopy(P,ZGDeTuile2); //P is the last inserted : It works always
        D.FindAndCopy(R,ZGDeTuile2);//R is the first inserted. It works at the beginning, and then after some iteration, doesn't work anymore.
So, I corrected the initial post. Sorry for that.

I saw in this forum the slice method but I didn't understand how and when to use it...

#3 Re: mORMot 1 » TWinHTTP.Get Elapsed time » 2019-05-27 12:50:28


Thanks ab, I will check this.

#4 Re: mORMot 1 » TWinHTTP.Get Elapsed time » 2019-05-27 09:23:51


Thanks a lot MPV for answering.

First you are rigth about the measurement tool. Accurate for 1 call but not accurate for 1000 call.

Second, if I use TPrecisionTimer, the result is the same: 50 ms per call (cmd windows still showing 5 or 6 ms).

#5 mORMot 1 » TWinHTTP.Get Elapsed time » 2019-05-23 16:48:41

Replies: 4

Hello mORMot users,

I'm using my own OSRM routing service on my virtual machine.
I'm running an OSM query (someting like over a delphi program (XE 6 Ent).
the CMD window show me the elapsed time (2 lines per call)


[info] 23-05-2019 18:26:47 4.29234ms - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...
[info] 23-05-2019 18:26:48 5.1023ms - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...

[info] 23-05-2019 18:26:49 5.11134ms - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...
[info] 23-05-2019 18:26:50 4.87088ms - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...

The sum is arround 10 milliseconds.

The Delphi program is looking like that:
  httpVar :=  '';
  Stopwatch := TStopwatch.StartNew;
  JSONContent := _Json(TWinHTTP.Get(httpVar));  //JSONContent is mORMot RawJSON Type
  Elapsed := Stopwatch.Elapsed;
  MemResult.lines.Add(FloatToStr(MilliSeconds) + ' ms');
The elapsed time is arround 50 milliseconds.

Is this difference normal? Do I have a way to reduce this duration in Delphi?


#6 Re: mORMot 1 » Modifying JSON » 2018-11-27 21:12:20


Thanks ab. Changing to PDocVariantData fix the problem.

#7 Re: mORMot 1 » Modifying JSON » 2018-11-25 20:17:19


Hi again.
Here is a piece of code.

procedure TForm1.Button1Click(Sender: TObject);
var iNbFeatures,j,iNbProperties :integer;
    vFeatures, vProperties: TDocVariantData;
  v := _JsonFast('{"features":[{"properties":{"Name":"blabla","Id":11}}]}');
  vFeatures := _Safe(v.Features)^;
  iNbFeatures:= vFeatures.Count;
  for j:=0 to iNbFeatures-1 do
    vProperties := _Safe(vFeatures.Values[j].properties)^;
    iNbProperties := vProperties.Count;  //Here iNbProperties = 2 .
    vProperties.Values[1]:= 'NEW VALUE FOR P1';  //Property.value is modified in the debbuger
    vProperties.Names[0]:= 'NEW NAME FOTR P0';   //Property.name is modified in the debbuger
    vProperties.AddValue('Level', 3);
    iNbProperties := vProperties.Count;  //Here iNbProperties = 3.
    vProperties.AddNameValuesToObject(['RRRR', 'RRRRR']);
    iNbProperties := vProperties.Count;  //Here iNbProperties = 4.
   But Here,
   v._JSON shows only initial properties modified}

New value of v is :
'{"features":[{"properties":{"NEW NAME FOTR P0":"blabla","Id":"NEW VALUE FOR P1"}}]}'
Only initial properties were modified. I can add property into vProperties but there is no propagation to vFeatures.


#8 Re: mORMot 1 » Filling a grid in Elevate Web Builder » 2018-11-24 14:54:39


Hi Horbs,

I got both Erick books, but finaly I decided to not use his wrapper (it is a little bit complicated for a newbie like me).

I'm tying to play with the couple EWB/Mormot.

Anyway, I've  got a problem about JSON unserialization on the client side. I don't know if this is relevant for you, but the JSON coming from Mormot was not OK for EWB.

I fixed it (very dirty) like this for the moment:

  GridJSON :=StrReplace(Request.ResponseContent.Text,'"result":[', '"rows":');
  GridJSON :=StrReplace(GridJSON,']}', '}');

If you have the rigth solution for this , let me know please.


#9 Re: mORMot 1 » Modifying JSON » 2018-11-23 20:08:23


I fixed the problem using TDocVariant like this

     v: Variant;
     vFeatures, vGeometry, vCoordinatesAll, vCoordinates,vLatLong: TDocVariantData;
     sFeatures,sTheValue : RawUtf8;

  // Load from Memo
  sFeatures:= _Json(MemJSON.Lines.Text)  ;
  v := _JsonFast(sFeatures);

  vFeatures := _Safe(v.Features)^;
  vGeometry := _Safe(vFeatures.Values[0].Geometry)^;
  vCoordinatesAll := _Safe(vGeometry.Values[0])^;
  vCoordinates := _Safe(vCoordinatesAll.Values[0])^;
  vLatLong := _Safe(vCoordinates.Values[0])^;

  vLatLong.Values[0] := '12'; //this works

#10 mORMot 1 » Modifying JSON » 2018-11-17 09:40:18

Replies: 4


I'm playing with JSON and I face a problem:
Here is a relevant piece of code.

  sFeatures:= _Json(MemJSON.Lines.Text)  ;                                                                 //Loading text from TMemo
  vFeatures := _JsonFast(sFeatures);                                                                             //vFeatures is Variant   
     vFeatures.Features._(0).properties.Id := 1111;                                                        //works well. I can change the value of Id
     sLat:=  vFeatures.Features._(0).Geometry.Coordinates._(0)._(0)._(0);                  //Works well. I can read the value and sLat is RawUTF8.
     vFeatures.Features._(0).Geometry.Coordinates._(0)._(0)._(0) := sLat;                   //EVariantDispatchError. I cannot copy back the same value
Obviously, I missed something in the documentation. Some ideas?


#11 Re: mORMot 1 » Serialize many records using CreateAndFillPrepare » 2018-10-23 20:00:18


I wrote this and It works fine.

function TServiceBiolife.BiolifeReadFromName(Common_Name: RawUTF8): RawJSON;
  result:= aServer.RetrieveListJSON( TSQLBiolife, 'Common_Name LIKE ' + QuotedStr(Common_Name + '%') , 'Common_Name,Category', True);

Thanks a lot ab.

#12 mORMot 1 » Serialize many records using CreateAndFillPrepare » 2018-10-21 13:09:36

Replies: 2


I build a server (interface based). For testing, i'm using this class:

TSQLBiolife = class(TSQLRecord)
    fCommon_Name: RawUTF8;
    fSpecies_Name: RawUTF8;
    fNotes: TSQLRawBlob;           


Now I'm trying to achieve CRUD over AJAX.
My main objective is to exchange JSON between Client and Server and to mimic as much as possible the TclientDataset.Delta behavior. 
I spent time reading the documentation and some presentation (FROM SQl to ORM ...).
I saw many functions about serialization but don't know how to do.
I check also the examples. I found only one (Samples\ThirdPartyDemos\Migajek\synopse-sqlite-demo) where we are building a list after CreateAndFillPrepare. Not JSON list and maybe not relevant, I don't know...

For example about reading Data (I would like to retrieve many records with only 2 or 3 fields for example), I tried :

function TServiceBiolife.BiolifeReadFromName(Common_Name: RawUTF8): RawJSON;
var aBioLife: TSQLBiolife;   
    //tmpResult : ???;   What to do here?
  TAutoFree.Create (aBioLife,TSQLBiolife.CreateAndFillPrepare(aServer,'Common_Name LIKE ' + QuotedStr(Common_Name + '%')));
  While aBiolife.FillOne do
    Writeln (aBioLife.Common_Name);            //This works as expected
    //tmpResult.AddItem( with Only Needed Fields)  ;        //What to do here?
  //result := ObjectToJSON (tmpResult);            //What to do here?

Please if you have some examples , it would help.

#14 mORMot 1 » sqlite3fts.obj » 2018-09-04 11:46:41

Replies: 2

Hi AB,

FYI sqlite3fts.obj is not inside http://synopse.info/files/sqlite3obj.7z

Maybe it's normal, just wanted to inform.

Kind regards.

#15 Re: mORMot 1 » Restfull authentication : Best pattern for registering a new user » 2017-03-24 16:05:49


Thanks Ab. I checked it, but I'm confused without example.

I will read the doc again and try to fix my problem.

#16 mORMot 1 » Restfull authentication : Best pattern for registering a new user » 2017-03-18 21:52:28

Replies: 3


I really like the "mORMot secure RESTful authentication".

But how to allow users to create their account and avoid DDOS Attack. In the "mORMot secure RESTful authentication", there is a secret shared between Server and client. But when the user doen't exist (he is creating an account), how to prevent replay attack by a MIM user?

Does something like this already handled by Mormot ?
  1 - The user authenticate via OAuth.
  2 - The server send a mail with a link (available for 1 hour for example).
  3 - The user click the clink and validate his account

Any advice?

#17 Re: mORMot 1 » Mormot Restfull Authorization handshake » 2017-02-10 09:26:18


Yes. Using GUID is a good idea. Thanks

#18 Re: mORMot 1 » Mormot Restfull Authorization handshake » 2017-02-09 17:11:56


I just realize now that my ClientNonce was not ok (too short).

#19 Re: mORMot 1 » Mormot Restfull Authorization handshake » 2017-02-09 13:18:17


I'm trying to continue my authentification process. Before trying with a third part tool, I'm trying to make it using Delphi like this :

procedure TForm1.DoAuth;
var ServerNonce,ClientNonce : String;
    _http, ModelRoot,CompleteRoot,ComputedPassword,UserName, PassWord, salt : string;
    JSONContent : RawJSON;
    doc : Variant;
  ClientNonce := '12345'  ;
  CompleteRoot :=  'http://localhost:888/root';
  ModelRoot :=  'root';
  Password := 'synopse';
  salt := 'salt';

  _http := 'http://localhost:888/root/auth?UserName=User'  ;
  Memo1.Lines.add (inttostr(MillisecondOfTheDay(Now)) + '  -  ' + '_http >>> ' + _http);
  JSONContent := _Json(TWinHTTP.Get(_http));
  Memo1.Lines.add (inttostr(MillisecondOfTheDay(Now)) + '  -  ' + 'JSONContent >>> ' + JSONContent);
  doc := _JsonFast(JSONContent);
  ServerNonce :=doc.result;
  Memo1.Lines.add (inttostr(MillisecondOfTheDay(Now)) + '  -  ' + 'ServerNonce >>> ' + ServerNonce);

  //Auth - Copy from documentation
    // $ GET ModelRoot/auth?UserName=...
    // $  -> returns an hexadecimal nonce contents (valid for 5 minutes)
    // $ GET ModelRoot/auth?UserName=...&PassWord=...&ClientNonce=...
    // $ -> if password is OK, will open the corresponding session
    // $    and return 'SessionID+HexaSessionPrivateKey'
    // The Password parameter as sent for the 2nd request will be computed as
    // ! Sha256(ModelRoot+Nonce+ClientNonce+UserName+Sha256('salt'+PassWord))

  ComputedPassword:= Sha256(ModelRoot+ServerNonce+ClientNonce+UserName+Sha256(salt+PassWord));
  _http := CompleteRoot + '/auth?UserName=User&PassWord=' + ComputedPassword + '&ClientNonce=' + ClientNonce;
  Memo1.Lines.add (inttostr(MillisecondOfTheDay(Now)) + '  -  ' + '_http >>> ' + _http);
  JSONContent := _Json(TWinHTTP.Get(_http));
  Memo1.Lines.add (inttostr(MillisecondOfTheDay(Now)) + '  -  ' + 'JSONContent >>> ' + JSONContent);



Here is the memo1.text:
51070884  -  _http >>> http://localhost:888/root/auth?UserName=User
51070897  -  JSONContent >>> {"result":"8432386e2c3b0e400891a239cc3678c90f26e43195559dda3e8111f692b880e5"}
51070897  -  ServerNonce >>> 8432386e2c3b0e400891a239cc3678c90f26e43195559dda3e8111f692b880e5
51070898  -  _http >>> http://localhost:888/root/auth?UserName=User&PassWord=fa8ae08c4e3210e7cc9b13b5b2a7188cddb405cc1323f7003084f785fa35c549&ClientNonce=12345
51070902  -  JSONContent >>> {"result":"8432386e2c3b0e400891a239cc3678c90f26e43195559dda3e8111f692b880e5"}

What is wrong with the second call (with password)?

#20 Re: mORMot 1 » Mormot Restfull Authorization handshake » 2017-02-03 23:18:13


Thanks ab.
I understand it better now.

#21 mORMot 1 » Mormot Restfull Authorization handshake » 2017-02-03 13:46:30

Replies: 6


I'm using Example 14 :
Project14Client and Project14ServerHttp
I'm trying HTTP/TCP-IP connexion (ComboProtocol.ItemIndex =0)
Everything works well.

In the code of Project14Client, I replace user by user222 (who doesn't exist):
    case ComboProtocol.ItemIndex of
    2:   TSQLRestServerAuthenticationNone.ClientSetUser(Client,'User','');
    else Client.SetUser('User222','synopse');
I got and error. So far so good.

Now, let's change client

In this video from warleyalex: https://www.youtube.com/watch?v=LIl1HbjxnIA
we can see the process I would like to mimic (about authorization).
Now I'm using a browser + The same server:

if : http://localhost:888/root/auth?UserName=User
result is : {"result":"42f4aeb81c1ef81f771f3de8abca9dcf66901c575530e7672e4b1146474ae650"}
So far so good

But if : http://localhost:888/root/auth?UserName=User222
  result is the same (User222 does not exist). This, I do not understand

In documentation : mORMot secure RESTful authentication

it is written :
                 Here are the typical steps to be followed in order to create a new user session via mORMot authentication scheme:

                 Client sends a GET ModelRoot/auth?UserName=... request to the remote server - with the above command, it will be GET ModelRoot/auth?UserName=User;
                 Server answers with a hexadecimal nonce contents (valid for about 5 minutes), encoded as JSON result object;

It is not written that the Nonce answer is only if the user exist

If the behavior I got whit the browser is correct:
  - does that mean we can handshake the server with any UserName which is not existing?
  - does that mean we could have the same Nonce all the day (if there is thousand users for example)
If the behavior is NOT correct, what did I miss?

Please help.

#22 Re: mORMot 1 » new book about mORMot » 2017-01-17 09:41:09


OK Erick,

For example, I cannot find the needed source to compile and run the delivered apps. For example, no wbp file in the ewbmormot.zip file.
And the ewbmormot.zip file is "only" 3.5 Mb. So it is not large (in my opinion).

I'm confused.

#23 Re: mORMot 1 » new book about mORMot » 2017-01-12 11:12:06



Indeed this sounds agreable.

About topics : if you plan to add a starter kit, my wish (people may have other wishes) is to study a starter kit based on example 14 with:
  - Handshake
  - Auth
  - Service call 1 : Getting a list of records. Json transmitted by Mormot Server.
  - Json unserialization from EWB
  - Transfering in Dataset/Grid in EWB
  - Modifyng grid in EWB (CUD)
  - Json Serialization
  - Service call 2 : Applying updates

Some of those points are already covered by your book.

Because I really believe in capabilities of EWB+ Morrmot couple, my proposition is to share this starter kit in Synopse web site and in EWB web site. It will help many beginers (like me) to create apps and wil bring audience to your book.
This starter kit will be also improved by the community.


#24 Re: mORMot 1 » new book about mORMot » 2017-01-09 15:14:07


Hi Erick,

I baught both of your book. 65 euros each. I was interrested about building apps with MORMOT + EWB. The price is expensive and I can understand it because there is not so much audience about Delphi or EWB. So I will not critic the price. You are also free to sell it the price you want. But:
- About the layout, I really don't understand. There was many pages to save (first for ecology, and for some other good reasons). For example, page 211: The page is well covered with Project 07;08 and a part of 09. Good  !! Page 230 : 1 line only. 235, 244 : 2 lines only. And many more...
- About code : A lot of code from Mormot Web site. Why not make them available from your web site or Github?
- The font size is quite big ( reduce it would save some paper)

I'm frustrated because i expected a complete small application including CRUD, Auth, Sharding, JSON (Un)Serialization, logging. Some kind of Starter Kit. I would pay 65 euros for this even if the book was 100 pages only.

I have to say that I'm glad that some people are writing books about MORMOT and EWB. Hope those remarks (critics) will help you to improve your next editions ;-)

#25 Re: mORMot 1 » Elevate Web Builder » 2016-10-20 21:29:26

ab wrote:

Best idea should be to create the mustache wrappers working with EWB, to directly generate the client code from the server.
See http://synopse.info/files/html/Synopse% … #TITLE_471

AB, Can you please explain why?
Is it a security issue?

About wrappers, AFAIK, you are the only one who wrote mORMot wrappers (For the SMS tool for example). How long dit it take to you to build the SMS wrapper?
Is there a kind of tutorial to do it?

#26 Re: Language » mORMot Café? » 2016-10-17 19:35:06



So, here is my g+ account:

mormotuser aat g** dot com.

Other Mormot users, feel free to contact me.

#27 Language » mORMot Café? » 2016-10-17 17:16:30

Replies: 2


I'm very new in mORMot. I wonder if there is some people interesting by meeting arround a coffee to exchange about mORMot and friends (after work meeting)

I'm leaving near Paris(France) and wonder if something like this exists?

A long time ago, I was in a restaurant in Paris with some people enjoying Pascalissime (review about pascal programming). That was a good way to exchange and share knowledge.

AB, What do you think about it? What would be the best tool (FAcebook? Whatsapp?Google?) to meet this?

#28 Re: mORMot 1 » Calling mORMot webservice from Java » 2016-10-17 16:50:51


Thanks WarleyAlex. In witch project did you copy/paste this?

#29 Re: mORMot 1 » Calling mORMot webservice from Java » 2016-10-13 19:12:40



I'm Newbie and I wonder if there is a way to find the URI string just looking to the server code.

For example, Project06Sever (remote JSON REST Service), I tried (on EWB) : http://localhost/Service/Sum?A=1&B=4...No success

#30 Re: mORMot 1 » Elevate Web Builder » 2016-10-13 15:59:34


Thank you WarleAlex. Finally I understood my mistake. I did download the file from Erick web page some times ago. In this version, no wbs file. Finally erick updated the file. Thanks again.

#31 Re: mORMot 1 » Elevate Web Builder » 2016-10-13 14:06:41


Hi Erick. I received the book and I tried to buid my first example using Mormot following given example. I just cannot find the EwbMormot.wbs code. Did I miss something?

#32 Re: mORMot 1 » Elevate Web Builder » 2016-09-18 09:46:44


Just for information, do You have an idea about the date of availability of your Mormot book?
If I'm not mistaken it's the first book on Mormot. Right?

#33 Re: mORMot 1 » Elevate Web Builder » 2016-09-13 13:50:50


Thanks Erick.

The Horbs's link worked for me also and I just ordered mine ;-)

#34 Re: mORMot 1 » Elevate Web Builder » 2016-09-13 09:32:13


Thanks Erick.

The Horbs's link worked for me also and I just ordered mine ;-)

#35 Re: mORMot 1 » Elevate Web Builder » 2016-08-17 05:43:21


Thanks Erick. Please Let us know when the proofed book will be available.

#36 Re: mORMot 1 » Elevate Web Builder » 2016-08-15 23:28:23


In your book, do you have an SOA example between EWB and Mormot or a chat example like this:

#38 mORMot 1 » With or Without SmartMobileStudio? » 2016-07-05 10:51:10

Replies: 2

Assuming that we want to use mORMot framework in a new mobile app build from scratch. Of course we would like also some basic cool UI components.
The app target some countries where internet connection is expensive and app will be often disconnected. So we need to (re)load the app very often.
Dealing with Websockets/callbacks in asynchronus way match exactly our client/Server needs.
We are also "old" Delphi developer without enought knowledge in HTML/JS/CSS. If we have to deal a little bit with HTML or CSS, it can be OK, but we really want to avoid JS.
The point is to find a way to use some tools + Mormot to build strong and nice UI App with Pascal skills. We need to write once and deploy anywhere.
We exclude Firemonkey because compiling and testing with Virtual Machine is very slow (on Delphi XE6). Yes we use XE6 and don't plan to buy new version.

So I used my best friend Google and finally I found 2 options:
1 - Morfik for Client and Mormot for server (but not sure for the moment we can use WebSockets/CallBack with mormot throught a web service. Not sure about the bandwith also. Not tried yet)
2 - SMS + Mormot

We downloaded Mormot + SMS , try some examples and was very excited about it. Because :
  We do not have to deal with JS.
  Bandwith is very good.
  Testing with SMS is fast.

But reading the previous messages about SMS make us a little bit afraid.  AB helped to build the first version and now is quite puzzled about the policy of SMS. Wrong?
We readed also the main SMS developer didn't work on the tool for 2 years.
There is (if I'm not wrong) 1 developer and the source is closed. It can be a support issue if this developer cannot help (for some reason). In this case, it would be possible to involve some HTML/JS skills and fix some issues. Right?

So our questions are : 
1 - Is it still a good choice to use SMS with Mormot?
2 - Is is risky for the future (5 next years)?
3 - Does exist some doc or tutorial about integrating cool UI components from other framework (something like the example from Wayre Alex about using UI from F7)? This question was already asked about ionic (and the answer is "not yet") but maybe someone used another framework or another tool.

Some other advices? Alternatives?


Board footer

Powered by FluxBB