You are not logged in.
Pages: 1
Hello,
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;
End;
to
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.
Hello,
I'm facing a TSynDictionary strange behaviour :
The code below works as expected...
-----------------------------------------------------
D:=TSynDictionary.Create(...);
P.I :=1119; P.J:=2220;
Setlength(Tuile,2);
Tuile[0].Nom := 'Toto';
Tuile[0].Coordonnees := 'gggg';
Tuile[1].Nom := 'Titi';
Tuile[1].Coordonnees := 'lll';
D.Add(P,Tuile) ;
D.FindAndCopy(P,Tuile2);
D.Free;
-------------------------------------------------------
Now, I've add a "CreateAndFillPrepare.." + While FillOne ... begin end;
------------------------------------------------------
D:=TSynDictionary.Create(...);
LienTuile:=TSQLXXX.CreateAndFillPrepare(...);
while LienTuile.FillOne do
begin
.....Some code....
Setlength(Tuile,..)
.....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)
end;
------------------------------------------------------------------
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...
Thanks ab, I will check this.
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).
Hello mORMot users,
I'm using my own OSRM routing service on my virtual machine.
I'm running an OSM query (someting like http://127.0.0.1:5000/route/v1/driving/...) over a delphi program (XE 6 Ent).
the CMD window show me the elapsed time (2 lines per call)
Examples:
[info] 23-05-2019 18:26:47 4.29234ms 127.0.0.1 - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...
[info] 23-05-2019 18:26:48 5.1023ms 127.0.0.1 - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...
[info] 23-05-2019 18:26:49 5.11134ms 127.0.0.1 - Mozilla/5.0 (Windows; mORMot 1.18 TWinHTTP) 200 /route/v1/driving/...
[info] 23-05-2019 18:26:50 4.87088ms 127.0.0.1 - 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 := 'http://127.0.0.1:5000/route/v1/driving/...';
Stopwatch := TStopwatch.StartNew;
JSONContent := _Json(TWinHTTP.Get(httpVar)); //JSONContent is mORMot RawJSON Type
Elapsed := Stopwatch.Elapsed;
MilliSeconds:=elapsed.Milliseconds;
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?
Thanks.
Thanks ab. Changing to PDocVariantData fix the problem.
Hi again.
Here is a piece of code.
procedure TForm1.Button1Click(Sender: TObject);
var iNbFeatures,j,iNbProperties :integer;
vFeatures, vProperties: TDocVariantData;
v:Variant;
begin
v := _JsonFast('{"features":[{"properties":{"Name":"blabla","Id":11}}]}');
vFeatures := _Safe(v.Features)^;
iNbFeatures:= vFeatures.Count;
for j:=0 to iNbFeatures-1 do
begin
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.
end;
{
But Here,
v._JSON shows only initial properties modified}
end;
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.
Why?
Thanks
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.
DKA
I fixed the problem using TDocVariant like this
var
v: Variant;
vFeatures, vGeometry, vCoordinatesAll, vCoordinates,vLatLong: TDocVariantData;
sFeatures,sTheValue : RawUtf8;
begin
// 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
Hi,
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?
Thanks
I wrote this and It works fine.
function TServiceBiolife.BiolifeReadFromName(Common_Name: RawUTF8): RawJSON;
begin;
result:= aServer.RetrieveListJSON( TSQLBiolife, 'Common_Name LIKE ' + QuotedStr(Common_Name + '%') , 'Common_Name,Category', True);
end;
Thanks a lot ab.
Hello,
I build a server (interface based). For testing, i'm using this class:
TSQLBiolife = class(TSQLRecord)
private
...
fCommon_Name: RawUTF8;
fSpecies_Name: RawUTF8;
...
fNotes: TSQLRawBlob;
published
....
end;
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?
begin;
TAutoFree.Create (aBioLife,TSQLBiolife.CreateAndFillPrepare(aServer,'Common_Name LIKE ' + QuotedStr(Common_Name + '%')));
While aBiolife.FillOne do
begin
Writeln (aBioLife.Common_Name); //This works as expected
//tmpResult.AddItem( with Only Needed Fields) ; //What to do here?
end;
//result := ObjectToJSON (tmpResult); //What to do here?
end;
Please if you have some examples , it would help.
Thanks esmondb.
Hi AB,
FYI sqlite3fts.obj is not inside http://synopse.info/files/sqlite3obj.7z
Maybe it's normal, just wanted to inform.
Kind regards.
Thanks Ab. I checked it, but I'm confused without example.
I will read the doc again and try to fix my problem.
Hi,
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?
Thanks.
Yes. Using GUID is a good idea. Thanks
I just realize now that my ClientNonce was not ok (too short).
Sorry.
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;
begin
ClientNonce := '12345' ;
CompleteRoot := 'http://localhost:888/root';
ModelRoot := 'root';
UserName:='User';
Password := 'synopse';
salt := 'salt';
Memo1.lines.Clear;
//handshake
_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);
//....
//....
end;
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)?
Thanks ab.
I understand it better now.
Hi,
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');
end;
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 : 21.1.3.2. 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.
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.
Erick,
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.
Sincerely,
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 ;-)
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?
Fantastic,
So, here is my g+ account:
mormotuser aat g** dot com.
Other Mormot users, feel free to contact me.
Hello,
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?
Thanks WarleyAlex. In witch project did you copy/paste this?
Hi,
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
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.
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?
Erick,
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?
Thanks.
Thanks Erick.
The Horbs's link worked for me also and I just ordered mine ;-)
Thanks Erick.
The Horbs's link worked for me also and I just ordered mine ;-)
Thanks Erick. Please Let us know when the proofed book will be available.
Erick,
In your book, do you have an SOA example between EWB and Mormot or a chat example like this:
http://matthew-jones.com/ewb-rosdk-getting-started/
Thanks. It helps me a lot.
Hi.
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?
Thanks.
Pages: 1