#1 Re: mORMot 2 » MVC rendering » 2025-07-16 04:48:43

Thank you @flydev for the detailed explanation. I think using the GetViewInfo function will be the easiest way for me.

#2 Re: mORMot 2 » MVC rendering » 2025-07-14 08:06:25

1 I start the МVС server, FlushAnyCache starts (reads and downloads all partials)
2 I start the browser
3 I open the page (partial is loaded and displayed on the page)
4 I change the html text in partial on the МVС server
5 ???
6 When updating the page, the data does not change (even if the cache is disabled in the browser and on the МVС server)
7 When the МVС server is restarted, everything is displayed perfectly when the browser page is refreshed.

I'm not really understanding where I need to call FlushAnyCache?

UPDATED: and I also don't quite understand the meaning of the variables.

  TMvcRendererCachePolicy = (
    cacheNone,
    cacheRootIgnoringSession,
    cacheRootIfSession,
    cacheRootIfNoSession,
    cacheRootWithSession,
    cacheWithParametersIgnoringSession,
    cacheWithParametersIfSession,
    cacheWithParametersIfNoSession);

#3 mORMot 2 » MVC rendering » 2025-07-14 06:21:48

Alek
Replies: 6

Hello everyone

Please tell me if it is possible to force the page rendering if the "mustache partial" has changed, but the html file itself has not?

#4 Re: mORMot 2 » Access violation writing to address » 2025-06-23 04:48:24

replace aHTTPSServer.RootRedirectToURI('blog/default'); // redirect / to blog/default

to aHTTPSServer.RootRedirectToURI('blog/default',true,true); // redirect / to blog/default

#5 Re: mORMot 2 » THttpClientSocket.OpenBind » 2025-05-28 12:46:47

This is the stack

#0 THttpClientSocket.OpenBind(THttpClientSocket($03DDEF98)
#1 THttpClientSocket.OpenOptions(THttpClientSocket($03DDEF98),
#2 TSimpleHttpClient.RawConnect(TSimpleHttpClient($008F33FC),
#3 TSimpleHttpClient.Request(TSimpleHttpClient($033F99C0),
#4 TJsonClient.RawRequest(TJsonClient($00348150),
#5 TJsonClientAbstract.RttiRequest(TJsonClientAbstract($00348150),
#6 TJsonClientAbstract.Request
#7 TOpenapiClient...


update:

this code JsonClient.Http.Options.Proxy:='none';    works for me

#6 Re: mORMot 2 » THttpClientSocket.OpenBind » 2025-05-28 12:36:12

procedure THttpClientSocket.OpenBind(const aServer, aPort: RawUtf8; doBind,
  aTLS: boolean; aLayer: TNetLayer; aSock: TNetSocket; aReusePort: boolean);
  //------- TLS=false; Tunnel.Server='localhost'; Tunnel.Server <> 'ip address'  - and go to inside
  //bak=Tunnel (the same proxy data)

#7 Re: mORMot 2 » THttpClientSocket.OpenBind » 2025-05-28 10:47:54

OS Windows, variables: HTTP_PROXY, HTTPS_PROXY, value http://localhost:3128

#8 mORMot 2 » THttpClientSocket.OpenBind » 2025-05-28 08:12:59

Alek
Replies: 6

Hello

After the function appears "THttpClientSocket.OpenBind" in the unit mormot.net.client i can't connect to remote local server, because a function try to do it through proxy server
I have a description of the proxy server in the environment variables, but i don't use them. I am accessing the server directly by IP address.

Without this function all works fine

What am I doing wrong?

#9 Re: mORMot 2 » the same names in the url parameters » 2025-05-28 07:37:10

Yes, that's what I really need. Thanks

#12 Re: mORMot 2 » How I can intercept ENetSock exception » 2025-04-14 05:46:24

Good morning

In my example, the RunClient function should catch all exceptions, including ENetSock. But it doesn't happen.

I wrote an example to show this.

#13 Re: mORMot 2 » How I can intercept ENetSock exception » 2025-04-11 13:00:41

1. I want to say, that an except block exist in the TSimpleHttpClient.Request method and it doesn't raise an exception higher. And my messagebox doesn't appear
2. It's ok

#14 mORMot 2 » How I can intercept ENetSock exception » 2025-04-11 11:17:23

Alek
Replies: 6

Hello everyone

How I can intercept ENetSock exception in an example below?

https://gist.github.com/delphiapp/2e4ec … 123a6aa4ab

and one more small point

the file "store3.dto.pas"  is generated with errors from "OpenApiPetStore3.json"

#15 Re: mORMot 2 » How can I reset HTTP_CLIENTERROR manually? » 2025-03-19 07:28:51

Good morning.

The translator doesn't always help me choose the right words.

After additional investigation, the TSimpleHttpClient.Request was discovered.

- I noticed the problem only when working with http
- the issue is with the hard-set {Retry}true parameter of the function
     result := fHttp.Request(
        Uri.Address, Method, KeepAlive, Header, Data, DataMimeType, {retry=}true);
-this parameter sets the ctxt.Retry := [rMain] property before attempting to reconnect again (if it is closed).
- next, when executing the THttpClientSocket.RequestInternal-DoRetry function (due to socket unavailability)
,the branch is executed:

if rMain in ctxt.Retry then
      // we should retry once -> return error only if failed twice
      ctxt.Status := FatalErrorCode

although there was no attempt to reopen the connection.

#16 mORMot 2 » How can I reset HTTP_CLIENTERROR manually? » 2025-03-17 12:23:28

Alek
Replies: 2

Hello everyone

A situation arises when working with TOpenApiClient - TJsonClient - TSimpleHttpClient mainly during debugging inside MVC server

- connection timeout occurs during step-by-step debugging in the IDE, after sending TOpenApiClient a request to the server
- when using the browser and when trying to re-request the MVC server by refreshing the page, the framework works, as it seems to me, in a contradictory way (mormot.net.client)
  - The function Request - RawConnect - SockConnected - shows the value "true"
  - The function fHttp.Request - sets the ctxt.Retry:= [rMain], then RequestInternal - fSock.Available(@loerr) - shows the value "false" and in DoRetry we get status=HTTP_CLIENTERROR

How can I reset this error condition manually?

#17 Re: mORMot 2 » Long wait for reading empty content » 2025-02-11 10:42:07

Everything is super!

Minor malfunction unrelated to the topic. An error occurred during compilation.

"mormot.core.variants.pas(7970): E2004 Identifier redeclared: 'p'". Conflict between a variable property P[const aNameOrPath: RawUtf8]

#19 mORMot 2 » Long wait for reading empty content » 2025-02-11 07:40:42

Alek
Replies: 4

I am executing the PUT method in OpenAPIClient

The update command itself is executed quickly. The content on the server is updated. The server returns the status 'HTTP/1.1 204 No Content'.

The header does not contain the "Content-Length" field, and therefore we get to the code section (mormot.net.http.pas) in "GetBody" procedure:

  else if Http.ContentLength < 0 then // -1 means no Content-Length header
  begin
    // no Content-Length neither chunk -> read until the connection is closed
    // also for HTTP/1.1: https://www.rfc-editor.org/rfc/rfc7230#section-3.3.3
    if Assigned(OnLog) then
      OnLog(sllTrace, 'GetBody deprecated loop', [], self);
    // body = either Content-Length or Transfer-Encoding (HTTP/1.1 RFC2616 4.3)
    if SockIn <> nil then // client loop for compatibility with oldest servers
      while not eof(SockIn^) do ////////////////////////////////////////////////// THERE IS A LONG TIMEOUT HERE, depending on the settings 
      begin
        readln(SockIn^, line);
        AppendLine(RawUtf8(Http.Content), [line]);
      end;

But the timeout is the same for everyone (connecttimeout, sendtimeout, recvtimeout)

How to solve this situation?

#20 Re: mORMot 2 » Pass ObjectOption parameter for PayLoad OpeAPI » 2025-02-11 05:53:09

Hello

I did this with the "explode" parameter.

According to the specification 3, when the value of the parameter explode = true for the array type, we get param=abc&param=xyz, and for the value of the parameter explode=false, we get param=abc,xyz

By default, the mORMot behaves like "explode" = true

It is enough to enter a check for the "explode" parameter

function TOpenApiParameter.Explode: boolean;
var lValue:Boolean;
begin
  if Data.GetAsBoolean('explode',lValue) then Result:=lValue
    else result:=true;
end;

....

if p.ParamType.IsArray and p.fExplode then
              w.AddDirect('*'); // ueStarNameIsCsv for UrlEncodeFull()
....

#21 Re: mORMot 2 » Pass ObjectOption parameter for PayLoad OpeAPI » 2025-01-28 06:27:10

It works perfectly.

Also a similar questions. Sometimes you need to pass a list of parameters in a query (array of simple type), id=1,2,3 but not as id=1&id=2&id=3
or name=str1,str2,str3 but not name=str1?name=str2&name=str3

mormot has an excellent opportunity to use the second way.

The lines are generated in the code:

'*id', IntegerDynArrayToCsv(id) or '*name', GetSetNameCustom(TypeInfo(TEnumNameArray))

If I remove the sign *, I will get the result I need.

How can I do this in an elegant way?

#22 mORMot 2 » Pass ObjectOption parameter for PayLoad OpeAPI » 2025-01-27 10:37:01

Alek
Replies: 5

Hello everyone!

Thank you, ab, for a great tool for working with OpenAPI.

How can I pass the ObjectOption parameter to Request (IJsonClient) method, so that the parameter PayLoad is saved to JSON only with non-empty values for POST method?

"required": [
  "projectId",
  "subject"
],
"properties": {
  "projectId": {
    "type": "integer"
  },
  "subject": {
    "type": "string"
  },
  "statusId": {
    "type": "integer"
  },
  "priorityId": {
    "type": "integer"
  }


For example:

PayLoad.ProjectID:=21;
PayLoad.Subject:='subject'
//PayLoad.StatusId:=0
//PayLoad.PriorityId:=0

OpenApiClient.IssueCreate(eo2Json,PayLoad, [woDontStoreDefault,woDontStoreVoid]);

PayLoad --> {ProjectID:21,Subject:'subject'}, but not {ProjectID:21,Subject:'subject',StatusId:0,PriorityId:0} as now

#23 mORMot 2 » Error in the function "AppendToFile" » 2024-02-28 08:54:56

Alek
Replies: 1

Hello everyone. I found an error. An example is below

program pAppend;

{$APPTYPE CONSOLE}

uses
  SysUtils, dialogs
  ,mormot.core.os
  ;

  var i:integer;
begin
  for I := 0 to 10 do
    AppendToFile(inttostr(i),'test.log');
  //only the last digit will be written to the "test.log" file   

  {
  in mormot.core.os
  Line 7148     FileSeek64(0, soFromEnd) // append

  need to insert a file's handle "h" to a function

  FileSeek64(h, 0, soFromEnd)
  }
  ShowMessage('ok');
end.

#24 Re: mORMot 2 » mORMot 2 Release Candidate » 2023-01-10 12:55:46

Another unsolved problem is the incorrect operation of the _ObjArrayClear function

I also get access violation

https://gist.github.com/delphiapp/33c66 … e87c51c4cf

because  line 5822 file mormot.core.rtti is
    RawObjectsClear(pointer(V), PDALen(PAnsiChar(V^) - _DALEN)^ + _DAOFF); in this function
must be
    RawObjectsClear(V^, PDALen(PAnsiChar(V^) - _DALEN)^ + _DAOFF);

#25 Re: mORMot 2 » mORMot 2 Release Candidate » 2023-01-10 08:42:03

I used Delphi 2006 Compiler and Stable Lazarus 2.2.4 Win32. In mORMot2 I got Access Violation from adress $00000000 when the programm is started

I have added compilation capability in Lazarus

https://gist.github.com/delphiapp/4450f … fcb4825e11

#26 Re: mORMot 2 » mORMot 2 Release Candidate » 2023-01-10 05:58:01

I have a problem with TRestHttpServer too

This is my test code (mORMot1 is Ok, mORMot2 is fail)

https://gist.github.com/delphiapp/95640 … 858068f326

The line where is a problem - 884 mormot.rest.http.server;

  log.Log(sllHttp, '% initialized for %', [fHttpServer, fDBServerNames], self);

#27 Re: mORMot 1 » Seriallize Error mORMot2 » 2022-08-31 07:23:22

One interesting feature turned out. When using the [jpoClearValues] parameter, the FinalizeAndClearPublishedProperties function is called and if the property is of type T*Objarray, the _ObjArrayClear function is called. This function not only frees the memory of array elements, but also deletes the array itself via _DynArrayClear.

But when we use the AutoDestroyFields function, if the property is of type T*ObjArray, then only the RawObjectsClear function is called. The array itself is not deleted

#28 Re: mORMot 1 » Seriallize Error mORMot2 » 2022-08-31 06:17:57

Good morning.

The probable cause of the error is an incorrect value of the first parameter of the RawObjectsClear function in the _ObjArrayClear procedure (line 5743, mormot.core.rtti)

there is -     

RawObjectsClear(pointer(V), PDALen(PAnsiChar(V^) - _DALEN)^ + _DAOFF);

must be-     

RawObjectsClear(V^, PDALen(PAnsiChar(V^) - _DALEN)^ + _DAOFF);

#29 Re: mORMot 1 » Seriallize Error mORMot2 » 2022-08-30 07:55:23

Please bear my foolishness. Why then is the T*ObjArray type property with the [jpoClearValues] parameter not released

See: https://gist.github.com/delphiapp/0e05d … e0f2697c17

#30 Re: mORMot 1 » Seriallize Error mORMot2 » 2022-08-30 05:53:47

You're right. In mormot 1, any previous instances of objects were forcibly released when json was loaded, but in mormot 2, it is now necessary to set the [jpoClearValues] parameter in the JsonFileToObject function. Thanks a lot.

#31 Re: mORMot 1 » Seriallize Error mORMot2 » 2022-08-29 07:19:45

Good morning. I have updated the example. See: https://gist.github.com/delphiapp/b2558 … 2cab5a6cc1

Since the class inherits from TSynAutoCreateFields, as I understand it, there is no need to prescribe a constructor and a destructor.

Thank you very much, Thomas, for wanting to help

#32 Re: mORMot 1 » Seriallize Error mORMot2 » 2022-08-26 18:52:24

Thanks a lot for your advices, but none of them helped. The error still exists.

#33 Re: mORMot 1 » Seriallize Error mORMot2 » 2022-08-26 08:22:59

Hello @ab. I got an error when reloading serialized data in Mormot2. When reloading data, an error appears when clearing T*ObjArray. File mormot.core.base, line 6996.

In version 1(switch the define) it's all right. You can reproduce the error through the source code.

https://gist.github.com/delphiapp/6d017 … 7c4402e0fe

#34 mORMot 1 » OneFieldValue mORMot2 » 2022-07-19 10:34:00

Alek
Replies: 0

Hello.

I am adding mORMot2 support to my project.

I met a pitfall. I attach an example of a project with an error. The variant with the error is controlled via a define "Test".

In mORMot1 I had a line code, which compile well in mORMot2, but doesn't work without a property ORM

ClientDB.OneFieldValue(TSQLRecordNames,'ID','Name=?',[],[StringToUTF8('Name3')]);

and a line

ClientDB.ExecuteJson([TSQLRecordNames],'SELECT * FROM Names')));

works equally well with and without a property ORM


https://drive.google.com/file/d/1MSuvW9 … sp=sharing

#35 Re: mORMot 1 » The attribute "dPUREPASCAL" affects the compilation of the project » 2022-07-18 08:40:56

Thanks for the quick response.

I don't want to define. Simply, the IDE just did it (added custom options) automatically without my knowledge

#36 mORMot 1 » The attribute "dPUREPASCAL" affects the compilation of the project » 2022-07-18 07:55:34

Alek
Replies: 2

Hello.

I have found a problem when compiling an empty project mORMot 1.18 in Lazarus IDE 32 bit, on Windows 64bit, intel core. May be it is not an error, but "As designed". But it took me quite a while to find the cause of the error. And I would like others to be able to avoid such a situation.

It turned out by chance when I converted the empty Delphi project with unit SynCommons to Lazarus and selected(checked) the compatibility with Delphi7.
The IDE automatically added these parameters to "Custom Options:  -dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL". The last attribute "-dPUREPASCAL" in these parameters leads to compilation errors

Build project the unit SynCommons I get 2 errors.

First of all, in a inplementation of function crc32cfast I see many errors like this:
SynCommons.pas(25067,17) Error: Unknown identifier "R8"
AFAIK R8 and R9 and so on, these are 64-bit registers, but I have IDE 32 bit.

And second, functions StrCompSSE42 and StrLenSSE42 is active in a declaration, but disable(gray colour, for a reason "defines") in an inplementation and consequently i see errors:
SynCommons.pas(2324,10) Error: Forward declaration not solved "StrCompSSE42(Pointer;Pointer):LongInt;" and
SynCommons.pas(2331,10) Error: Forward declaration not solved "StrLenSSE42(Pointer):LongInt;"


Is it necessary to describe this situation to users?

#37 Re: mORMot 1 » Seriallize Error mORMot2 » 2022-05-24 12:39:43

Good afternoon. Please, tell me about how I can save a variant as a json object, but not as a json Array? By default mORMot1 save the variant as an object, and mORMot2 as an array.

https://gist.github.com/delphiapp/d9e89 … f3ea1080f0

#39 mORMot 1 » Seriallize Error mORMot2 » 2022-05-13 08:20:02

Alek
Replies: 16

Good morning.

I wanted to do a trick, to persist data of record(structure) throught a variant published field. I use pre unicode version Delphi.

Well. I run my code with mormot1(switch the VER2 directive) and it work very well(all fields are serialized), but with mormot2, I get an error.

Here is my code ready for compile and json file "SaveAll.json"

https://gist.github.com/delphiapp/5e1e4 … 796d9b9a8a

#40 Re: mORMot 1 » Problem with the function "GetSetNameValue" in mORMot2 » 2021-12-14 06:08:33

Yes, it is. Everything works perfectly in Delphi and Lazarus

#41 Re: mORMot 1 » Problem with the function "GetSetNameValue" in mORMot2 » 2021-12-13 13:25:19

Ok. I will be use

GetSetNameValue(TypeInfo(TSetMyEnum), pEnum, endofobject);

instead TypeInfo(TSetMyEnumPart), where TSetMyEnum = set of TMyEnum;

And all passes.

#42 Re: mORMot 1 » Problem with the function "GetSetNameValue" in mORMot2 » 2021-12-13 11:19:34

Thanks for the clarification. But when I ran your a new test, I get an error. I am using BDS 2006.

#43 mORMot 1 » Problem with the function "GetSetNameValue" in mORMot2 » 2021-12-13 08:45:48

Alek
Replies: 6

Good day. I found the following problem when working with sets. Change a directive VER2 and see result.

program Project;

{$APPTYPE CONSOLE}

{$DEFINE VER2}

uses
  SysUtils
  {$IFnDEF VER2}
  ,SynCommons
  {$ELSE}
  ,mormot.core.base, mormot.core.json
  {$ENDIF}
  ;

type
  TMyEnum = (enOne, enTwo, enThree, enFour, enFive);
  TMyEnumPart =enTwo..enFour;

  TSetMyEnumPart = set of TMyEnumPart;


var pEnum:PUTF8Char; s:RawUTF8;endofobject:Char;

begin
  s:='["enTwo"]';
  pEnum := PUTF8Char(s);
  GetSetNameValue(TypeInfo(TSetMyEnumPart), pEnum, endofobject);
  if pEnum <> nil then
    Writeln('Error')
  else
    Writeln('Success');
  readln;  
end.

#44 Re: mORMot 1 » Indent record » 2020-09-28 08:58:29

Thank you. It works very well;

#45 mORMot 1 » Indent record » 2020-09-28 08:01:28

Alek
Replies: 2

Hello everyone. I want to serialize some records to a file. These records are inside object. When I writing code, as sample:

recapparat:=GetParamApparatUstr;
AddString('ParamApparat:');
AddRecordJSON(recapparat,TypeInfo(TApparatDataUstr));
Add(',');
....

I got:
{
ParamApparat:{
    TrToka: [0,1,2,3,4,5,6,7],
    TrTkOtb: [3],
    TrNapr: [8,9,10,11,12,13,14],
    Vhody: [16,16,16],
    Rele: [16,16,16]
}
}

How I can get this(to indent all fields of records?):
{
    ParamApparat:{
        TrToka: [0,1,2,3,4,5,6,7],
        TrTkOtb: [3],
        TrNapr: [8,9,10,11,12,13,14],
        Vhody: [16,16,16],
        Rele: [16,16,16]
    }
}

Thank you.

#46 mORMot 1 » Different behavior when saving » 2019-09-19 12:39:44

Alek
Replies: 1

I noticed different behavior when saving a dynamic array of strings and a dynamic array of records. Should it be? I use pre-unicode version Delphi - BDS2006. When I compiled in Delphi XE4, it's all values the same

Here is the code.

program pStrangeSave;
{$APPTYPE CONSOLE}
uses
  SysUtils,SynCommons,mORMot;
type
  TListKanalov = array of string;
const
  __Rec = 'name string';
type
  TRec = packed record
    name:string;
  end;
  TListRecKanalov = array of TRec;
var
  Kanals : TListKanalov; RecKanals : TListRecKanalov;
  da,daRec:TDynArray; i:Integer; s: RawUTF8;
const
  ArrStr : array [0..2] of string = ('фаза1','фаза2','фаза3');//cirillic name
begin
  TJSONSerializer.RegisterCustomJSONSerializerFromText(TypeInfo(TRec),__Rec);
  SetLength(Kanals,3);
  for i := 0 to 2 do
    Kanals[i]:=ArrStr[i];
  da.Init(TypeInfo(TListKanalov),Kanals);
  SetLength(RecKanals,3);
  for i := 0 to 2 do
    RecKanals[i].name:=ArrStr[i];
  daRec.Init(TypeInfo(TListRecKanalov),RecKanals);
  with TTextWriter.CreateOwnedStream() do begin
    AddDynArrayJSON(da); AddCR; AddDynArrayJSON(daRec); SetText(s);
  end;
  FileFromString(s,'strange.txt');
end.

#47 Re: mORMot 1 » Samles - 01 In Memory ORM error » 2018-07-19 16:59:34

I had the same problem. I used newpascal to compile and it's all become ok. You need unit - fpcsrc\rtl\objpas\typinfo.pp.

#48 Re: mORMot 1 » bug with JSON parsing » 2018-01-29 05:06:41

Check your json at least one online validator. https://jsonformatter.org/ https://codebeautify.org/jsonvalidator https://jsonlint.com/ You can see, that your data is not correct.

#49 Re: mORMot 1 » Strange behavior of "GetJSONValues" » 2015-09-29 08:04:58

thank you very much, now it works very well

#50 Re: mORMot 1 » Strange behavior of "GetJSONValues" » 2015-09-29 07:23:20

thank you, but have to

[
	{
		"ID": 1,
		"IDZakaza": 1,
		"IDTipoisp": 1,
		"SerNomer": "",
		"Otchety_nastrk": "{\"Href\":\"\",\"Report\":\"\",\"Result\":\"\",\"DateTest\":\"\"}",
		"Otchety_termo0": "{\"Href\":\"\",\"Report\":\"<html></html>\",\"Result\":\"Success\",\"DateTest\":\"29.09.2015 10:35:52\"}",
		"Otchety_termo8": "{\"Href\":\"\",\"Report\":\"\",\"Result\":\"\",\"DateTest\":\"\"}",
		"Otchety_termo16": "{\"Href\":\"\",\"Report\":\"\",\"Result\":\"\",\"DateTest\":\"\"}",
		"Otchety_termo24": "{\"Href\":\"\",\"Report\":\"\",\"Result\":\"\",\"DateTest\":\"\"}",
		"Otchety_termo36": "{\"Href\":\"\",\"Report\":\"\",\"Result\":\"\",\"DateTest\":\"\"}",
		"Otchety_termo48": "{\"Href\":\"\",\"Report\":\"\",\"Result\":\"\",\"DateTest\":\"\"}",
		"Otchety_termo72": "{\"Href\":\"\",\"Report\":\"\",\"Result\":\"\",\"DateTest\":\"\"}",
		"Otchety_Koeff": "{\"Href\":\"\",\"Report\":\"\",\"Result\":\"\",\"DateTest\":\"\"}",
		"Otchety_HtmKoeff": "{\"Href\":\"\",\"Report\":\"\",\"Result\":\"\",\"DateTest\":\"\"}",
		"Otchety_Test": "{\"Href\":\"\",\"Report\":\"\",\"Result\":\"\",\"DateTest\":\"\"}"
	}
]

I have code from 7 july 2015

Board footer

Powered by FluxBB