You are not logged in.
Result of testing with mormot2 (mormot.core.zip )
mormot2tests ( write.zip ): no header errors reported
My test with 1 file: no header errors reported
Another test generating 3 zip files with 3000 documents each one: no header errors reported
So no errors whatsoever.
Thank you ! I see you did a nice unit layout in mormot2 and there is no collision name risk, Maybe I'll dare to make the switch
I'm not on mormot2, but I've tried the latest SynZip from GitHub, let me download mormot2 and run the tests to confirm.
I'll be right back
Hi Arnaud
I'm not able to find what can be the cause of this, let me explain:
I am creating at runtime a lot of XML Documents ( TXMLDocument ) which I must add to a ZIP file to send them over the network to a third party, this was an existing project which was already creating the XML and using the SaveToFile method to store them on disk, then, to create the compressed file(s) I used TZipWrite to add the xml files using the AddDeflated method like this:
ZIPFile.AddDeflated('test.xml');
This works and the created files are ok, but, because there are more than 20,000 xml files, do it this way is slow, so instead of saving the XML to disk, at runtime I am storing the XML.Text property of each generated documento on a RawByteString variable (strXML):
strXML := xmlObj.XML.Text
and then doing:
ZIPFile.AddDeflated('test.xml', pointer(strXML), length(strXML) );
Using this method the process is much faster and I can open the final zip, see the files, uncompress them, but the software of the third party which process this ZIP files refuses to process them, he tells me they are corrupt and as a proof he asked me to extract them with 7zip and indeed 7zip says: Headers Error
I did a test with just one XML, adding it from a saved XML on disk, and opening the ZIP file in 7Zip I can se this in File - Properties
Size: 3 745
Packed Size: 2 106
Folders: 0
Files: 1
CRC: 166FAA28
Type: zip
Physical Size: 2 226
Adding the XML to the zip using the variable, these are the properties of the resulting file on 7Zip
Size: 3 745
Packed Size: 2 106
Folders: 0
Files: 1
CRC: 166FAA28
Warnings: Headers Error
Type: zip
Physical Size: 2 226
I can not see the difference but there is undoubtedly one, how can I add the documents without first saving them to disk and that the headers are correct?
Regards,
Mocte
I will explore that feature
Thank you !
The same user credential could be used in several places at the same time, each connection with its own session.
This is a feature of the current implementation, and changing it could break a lot of existing code.
Ok, I thought maybe I could do it by changing the value of some property I can possibly do it in some server event, any suggestions?
So a single session per user could be added as an option.
Do you still use mORMot 1?
Yes, I'm still on 1
Good day
Is it possible to invalidate an already created user session on the server if the same user login again on another device, browser, etc. let's say the user logs in on one computer, he has his sessionkey for signing requests, then the same user logs in on another computer and now gets another session key and is making signed requests from two places, is it possible that on the second login the first session is invalidated ?
Update
I've removed the protocol name now! It depends on the client lib which API is used. Using firebird3+ with the legacy API can be improved by choosing the "interbase" protocol name. Thus the name was superfluous. It will be mentioned in the rease notes.
Great, thank you !
Lorbs, looking what you're doing ... why the hell.. You convert a valid TDateTime value to a Raw-String?
Isn'tfDbConnection.Execute( 'select field1, field2 from mytable where mytable.UPDATED_AT >= ?', [aTimeStamp] );
exactly what you want? Or does it not work?
OTH the 'T' delimiter is desturbing most sql db's. MSSQL prefers the packed format without any delimiters, oracle as well. Firebird, MySQL, PostgreSQL, ASE, ASA simply don't understand this format it's just for SQLite and MongoDB, and the JSON's usefull, thought.
Well I'm here to learn in fact your snippet is better I mainly use mORMot as a kind of proxy usually the data is coming from another api, I'll follow your advice and give it a try
Do you know if PROTOCOL can be somehow changed to firebird3up on TSQLDBZEOSConnectionProperties ? I suppose it would be more appropriate
Thanks
I want to apologize, there was a wrong config setting from my side (somewhere along the testing I did this ), so the queries made with TZQuery were executed against a test database and (ouch!) the SynDB where being executed against a dev database, so the advice from @tbo about DateTimeToIso8601 was the definitive answer for getting this running with parameters sorry if i wasted your time, it is already working as it should.
What is the UPDATED_AT column type in the DB?
The type is TIMESTAMP
you have to call DateTimeToIso8601() directly with the correct parameters
ok, so now I did this :
fDbConnection.Execute( sqlText, [DateTimeToIso8601(fechaConsulta,true,' ',False)] )
Now the relevants lines of the log ( using a simplified query from the actual database ) :
20200729 14234861 # DB SynDBZeos.TSQLDBZEOSStatement(024efb60) Prepare 28us SELECT PRODUCTOS.CODIGO,PRODUCTOS.DESCRIPCION, PRESENTACIONES.neto10 FROM PRODUCTOS INNER JOIN PRESENTACIONES ON (PRODUCTOS.CODIGO = PRESENTACIONES.CODIGO) where presentaciones.updated_at >= ?
20200729 14235025 # SQL SynDBZeos.TSQLDBZEOSStatement(024efb60) ExecutePrepared 786.08ms SELECT PRODUCTOS.CODIGO,PRODUCTOS.DESCRIPCION, PRESENTACIONES.neto10 FROM PRODUCTOS INNER JOIN PRESENTACIONES ON (PRODUCTOS.CODIGO = PRESENTACIONES.CODIGO) where presentaciones.updated_at >= '2020-07-22 01:00:00'
So using DateTimeToIso8601 results on the same sql sentence I previously tested ( without parameters ) and is still returning 0 rows instead of 3.
Edit: The SQL from the log (ExecutePrepared) I can use exactly that with TZQuery and the result is 3 rows
Hi folks,
I don't really use the ORM but this time I wanted to take advantage of FetchAllAsJSON method, sadly i can't make a query behave, let's say I have a table in the database with a field ( UPDATED_AT Timestamp ) so I can query like this:
select field1, field2 from mytable where mytable.UPDATED_AT >= :FECHA
The previous sentence used in a TZQuery gaves the expected results ( 3 rows in my case )
This also works fine:
select field1, field2 from mytable where mytable.UPDATED_AT >= '2020-07-22 01:00:00'
For the ORM For querying I'm using
select field1, field2 from mytable where mytable.UPDATED_AT >= ?
and executing the query like this
var
aTimeStamp: TDateTime;
Begin
aTimeStamp := EncodeDateTime(2020, 7, 22, 1, 0, 0, 0);
fDbConnection.Execute( 'select field1, field2 from mytable where mytable.UPDATED_AT >= ?', [DateTimeToSQL(aTimeStamp)] );
End
Gaves 0 records for the same param value, and it doesn't matter if I pass the date as a parameter or if I include it as text I will get 0 rows.
I had the code done using old versions of UNIDAC/mORMot with the same results and because of this, I thought it was better to update mORMot to the latest, so I cloned the mORMot git repo, same for Zeos ( Im using 7.3 ) but it didn't make a difference, so I don't think it was a problem with unidac, nor with zeos.
Do any of you know how to get the same results query with the ORM as with direct ZEOS/Unidac ?
P.S. I am using Firebird 3, and Delphi 2007 for this, I can see zeos has a property PROTOCOL which can be firebird3up or firebird, couldn't find how to use firebird3up.
P.S.2 The database is legacy and in fact I'm not using the ORM just the SynDB stuff.
There are snapshots with with fpc 3.2 RC/fixes available here:
Lazarus 2.0.8 - FPC 3.2 RC/FIXES
I haven't tested myself because I'm already on trunk but maybe it's worth trying with them
@Chris75018 I couldn't find the time to check the updated demo until today, works like a Charm !! We are still pretty busy devoloping the services and testing them without authentication, I hope to be trying out with authentication very soon, your sample and @Emartin's code are extremely useful to me.
Hi @Chris75018
I just downloaded your demo to give it a quick glance, and although I have XE3 on my personal computer, for this project I must use XE and sadly this :
JwtHelperForlAuthenticationMode = record helper for lAuthenticationMode
Seems not supported on XE, I will try later with XE3 but I must find out how to replace that code to make it work on XE, either way, it's very nice of you to share this code with us, thank you.
@Chris75018 Great! Thank you
Thank you @Chris75018 I'm still busy making new services and once I finish I'll take a deep dive into this, maybe (just maybe) you will have me here asking more questions .
I used what I wrote in my last post.
Thank you Esteban, well I'll have to dig into that.
Hi @ab, @EMartin
Is this the ultimate solution ? I have a similar requirement, give access to a third party to some interface based services and I will like to use JWT for that.
Couldn't find any example project using JWT and I thought it would be better asking before start coding
Thank you
This means you are using uninitialized variables in your code (accessing to a var inside a function before variable is initialized)
Well in the demo I posted there isn't much code, let's review the code which triggers the error (the implementacion of the interface) :
function TClientesAdmon.RegistrarCliente(const datos: TCliente; out IdCliente: Int64): TResRegistroCliente;
begin
IdCliente := 1;
result := rrcExito;
end;
A const parameter which comes from outside, an out parameter which is returned as 1, and the result of the function which has his value assigned, I think there isn't much to look at here, the error that is obtained when calling the method is:
TServiceFactoryClient.Create(): IClientes interface or TSQLRestRoutingREST routing not supported by server [{
"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"
}]
{
"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"
}
Speaks of the interface and authentication, so we could review the relevant code involved on the creation of the server:
fModel := CreateModel(fParams.root);
fRest := TSQLRestServerDB.Create(fModel, fParams.archivoDB, fParams.enableAuth);
fRest.Model.Owner := fRest;
fRest.DB.Synchronous := smOff;
fRest.DB.LockingMode := lmExclusive;
fRest.CreateMissingTables;
fRest.ServiceRegister(TClientesAdmon.Create(fRest),[TypeInfo(IClientes)]);
ServidorHTTP := TSQLHttpServer.Create( fParams.Port, [TSQLRestServer(fRest)]);
ServidorHTTP.AccessControlAllowOrigin := '*';
The f* variables are private fields of the server class, the ServidorHTTP is public, I'm failing to see where could be an unitialized variable in my code, Alfred made some tweaks here and there to my code but it doesn't prevent the error, so if that is the case I couldn't find the source of it, the documentation I found of the -gt switch is:
Trash local variables. This writes a random value to local variables at procedure start. This can be used to detect uninitialized variables. The t can be specified multiple times
I believe I can compile safely without it, maybe there are places on mORMot code that fall into that case but that's something I can not say for sure.
*Edit: spelling
My original project is working now, the solution was uncheck the following option :
Project Options - Compiler Options - Debugging - Trash variables (-gt)
Thank you all.
Please try my version of your sources.
For me, these work ... ;-)
Thank you !
Your project ran without any error. So I compared the .pas files one by one in order to integrate your changes to my project and have them almost identical, didn't worked the error continued to appear no matter what would have changed, but I had left out from the comparison the .lpi file which had compiler options because I thought the problem was on my code, so as a last resort I patched my .lpi with yours and on the next build everything automagically worked, so the problem must be some compiler options.
How did I configured my project ?
1. Project - New project
2. Project - Project options
3. In compiler options I choose Create Debug and Release modes
Maybe the third step made some adjustments that affected the way mORMot works ? I'll try to investigate further, just FTR iin case someone else is faced with this problem
Thank you again Alfred
Hi AOG, I don't want to interrupt your holidays but I have to ask because I've had this thing on hold for some days.
Did you find some time to look for a possible solution?
Would you advise me to continue the development with the Delphi compiler while the problem is solved for FPC ? I mean if it is within your reach to solve it
Anything you can comment on will be useful for us.
Thank you AOG ! I thought I was going crazy.
1) to define your records as packed
2) to register the record serialization as text (see the doc)
Thank you AB but that it's not the problem, for the sake of the demo I deleted those lines ( I thought they weren't needed ).
My TCliente record is alreadey defined as packed and on my original project I have in the interface unit the following lines:
const
__TCliente = 'ID Int64 Nombre, Direccion RawUTF8';
initialization
Begin
TTextWriter.RegisterCustomJSONSerializerFromText(TypeInfo(TCliente),__TCliente).Options := [soReadIgnoreUnknownFields,soWriteHumanReadable];
TInterfaceFactory.RegisterInterfaces([TypeInfo(IClientes)]);
End;
Doesn't make any difference, I still got the very same error.
When stripping things out I left some custom paths on compiler options, I hope that is not a trouble for you, also compiled that demo on an older Lazarus trunk installation on Ubuntu 16 ( the checkbox is not visible there, don't know if the .lfm file format has changed ), I had the same results no joy consuming services from a TSQLRestServer created with the HandleUserAuthentication parameter set to TRUE.
*Edit: versions on Ubuntu - mORMot 1.18.3778 FTS3
The SOA Tests all pass on Delphi/Lazarus Windows/Linux
I realize I didn't posted the complete text of the error message, here it is :
TServiceFactoryClient.Create(): IClientes interface or TSQLRestRoutingREST routing not supported by server [{
"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"
}]
{
"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"
}
Thank you AB, perhaps is a misunderstanding on my side of how authentication works, I put a minimum project on BitBucket; it is a stripped down project (in fact it really does nothing besides playing with authentication).
https://bitbucket.org/mocte/demo_mormotfpc/src/master/
The same project contains server and client code, I put a checkbox on it to enable authentication, I'm not using AuthenticationRegister(), just changing aHandleUserAuthentication parameter on RestServer creation, when this parameter si set to true, the register customer button fails, the same code compiled on Delphi runs fine (in my original project at least).
Seems like nobody is using FPC with the default authentication on a setup like the one posted, I don't know what else to do, there are coworkers already suggesting doing project on another technology (you name it go, elixir, etc ) but I don't like abandoning projects halfway and also I have hope I can do this with FPC because is already working with Delphi, I can continue the development that way, but I'm not confident to go on because if I finish the work with delphi I won't be able to deploy to a Linux server (which is a must), so if anyone has tips, recommendations on how to get over this I'll be thankful.
Why do you call AuthenticationRegister()?
Reason number one, because on the two other projects I did it that way without any problems so far (the servers are compiled with Delphi and running on Windows), I already have other FPC compiled server running on Linux but there was no need for authentication on that project.
The default authentication is always there by default.
Mmm, then I have something else wrong because without AuthenticationRegister() anybody can do things like this on the browser :
http://localhost:4299/rootapi/?sql=SELECT%20RowId,%20LogonName,%20DisplayName%20FROM%20AuthUser
And get the data :
[{"ID":1,"LogonName":"Admin","DisplayName":"Admin"},{"ID":2,"LogonName":"Supervisor","DisplayName":"Supervisor"},{"ID":3,"LogonName":"User","DisplayName":"User"}]
I don't want that behavior
So I'm calling AuthenticationRegister() so the answer to such requests will be :
{
"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"
}
That is what I expect.
Tried without AuthenticationRegister() but then the ORM seems to be open in the wild again, to avoid calling AuthenticationRegister() I changed the aHandleUserAuthentication parameter on RestServer creation to True :
fRest := TMyRestServerClass.Create(fModel, fConfig.Conexion.DatabaseName, True);
But then I am where I started. The FPC compiled server is giving 403 on any call from the client and the Delphi one is working as I think it should, so if there is anything else I must be doing Could you please tell me what it is ? In any case I don't understand why the difference in behavior between the two compiled servers.
I did another test, and also I realized that my report is incomplete, the error ocurrs with a server compiled with Lazarus/FPC trunk ( FPC 3.3.1, Lazarus 2.1.0 )
My tests :
- Server compiled with Lazarus and client compiled with Lazarus -- ERROR 403
- Server compiled with Lazarus and client compiled with Delphi (XE3) -- ERROR 403
- Server compiled with Delphi (XE3) and client compiled with Delphi (XE3) -- SUCCESS
- Server compiled with Delphi (XE3) and client compiled with Lazarus -- SUCCESS
So as far as I have tested the problem is just when the server is compiled with Lazarus, but since I need this server running on a Linux server, Delphi is not an option because XE3 does not have a Linux compiler and I don't want to upgrade to the latest version, in fact we are getting away from Delphi.
Does anybody faced this problem already? Any hints ?
I'm going back and forth to mORMot from time to time, this time I need to develop a server for which I think mORMot (including the ORM and SQLite ) wold be a good fit, I did in the past a couple of servers with Interface based services using TSQLRestServerAuthenticationDefault ( no ORM ) which are running fine, I'm comparing the sources of all and failing to see what is causing the troubles when consuming the services with authentication, I think I'm missing something but can't see what it is, I hope someone here know the reason :
Server ( interface definition )
Interface
Types
TResultadoRegistro = (rrcExito, rrcYaExiste, rrcErrorDeBaseDeDatos);
IClientes = interface(IInvokable)
['{1DFFC3D9-474E-4B15-B2D7-0B42BB42A608}']
function RegistrarCliente( const datos: TCliente; out IdCliente: Int64): TResultadoRegistro;
end;
initialization
TInterfaceFactory.RegisterInterfaces([TypeInfo(IClientes)]);
// Concrete class
TClientesAdmon = class(TInterfacedObject, IClientes)
protected
fRest: TSQLRestServerDB;
public
constructor Create( ORM: TSQLRestServerDB ); reintroduce;
function RegistrarCliente( const datos: TCliente; out IdCliente: Int64): TResultadoRegistro;
end;
// ORM
fModel := CreateModel(fConfig.Root);
fRest := TMyRestServerClass.Create(fModel, fConfig.Conexion.DatabaseName, false);
fRest.Model.Owner := fRest;
fRest.DB.Synchronous := smOff;
fRest.DB.LockingMode := lmExclusive;
fRest.CreateMissingTables;
fRest.AuthenticationRegister(TSQLRestServerAuthenticationDefault); // <--- Register authentication causes troubles on client calls
fRest.ServiceRegister(TClientesAdmon.Create(fRest),[TypeInfo(IClientes)]);
// HTTP Server
ServidorHTTP := TSQLHttpServer.Create( config.Port, [TSQLRestServer(fRest)]);
ServidorHTTP.AccessControlAllowOrigin := '*';
Client side
Model := CreateModel( paramsSrv.root );
result := TSQLHttpClient.Create( paramsSrv.Host, paramsSrv.Port, Model, https);
TSQLRestServerAuthenticationDefault.ClientSetUser(apiClient, User, Pass);
apiClient.ServiceDefine([IClientes],sicShared); // <-- THIS LINE CAUSES THE ERROR 403
The error :
TServiceFactoryClient.Create(): IClientes interface or TSQLRestRoutingREST routing not supported by server [{'
'"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"
}]
{"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"}
If I don't use authentication then I can consume the services and everything runs smooth so it seems I could be missing a config or something ?
So back to the basics
Thank you!
I'm looking at the samples ( 35 - Practical DDD ) I can see in DomConferenceServices.pas a function with the following declaration
function TConferenceBooking.RegisterAttendee(const Name: TAttendeeName;
const FirstName: TAttendeeFirstName; const Days: TSessionDays;
out Attendee: TAttendee): TRegisterAttendee;
AFAIU consuming the service from a mORMot client the out parameter Attendee: TAttendee will have the newly registered attendee data and the function result will be one of: raSuccess, raAlreadyRegistered or raPersistenceError, but if the service is consumed from a browser I suppose the data returned would be only the function result? Am I right? or the out variable is available as part of the JSON returned to the browser ?
Regards
Mocte
Great ! I wish I had known this before :-) but it's never too late.
Thank you edwinsn.
I'm recommend to get a sources from a mORMot GitHub repository
It's include all libraries required for build mORMot for all supported platforms.
Also I update WiKi - thanks!
I always pull from the mORMot github repository.
Indeed the official way should be getting the sources from github repository (or fossil?? ), today I was playing with a new VM and the only way to compile TestSQL3 was pulling it from Github due to the lack of many static files on the nightly build, so from now on I will do that way, btw I also tried compiling with Lazarus 2.0 Release Candidate 2 with no luck, I had to use trunk ( thanks FPCupDeluxe ) and then everything went smooth, now back to play.
Great ! Seems like this page:
https://synopse.info/fossil/wiki?name=Get+the+source
Should be updated, the current text says
Therefore, sqlite3.obj and sqlite3fts.obj are available as a separated download
Thank you MPV
Seems like https://synopse.info/files/sqlite3obj.7z does not include sqlite3fts.obj anymore, I have one from 2016 but I don't think is safe to use it with the latest mORMOt version.
Does anyone have the latest version of this file ?
Here I am again, TInterfaceFactory.RegisterInterfaces solved the issue, then I faced the following error :
DescribeParams is not a valid option name for InterBase UniProvider
So I modified SynDBUnidac.pas and commented out the line :
// fSpecificOptions.Values['Interbase.DescribeParams'] := 'true';
The code now runs and I can consume the service from a client application, I don't know what would be the implications of such change, I followed a link to devart site on SynDBUnidac.pas but seems it is not there anymore.
Then I have more questions about the constructor of TSQLDBUniDACConnectionProperties, it has the code:
fSpecificOptions.Values['CharSet'] := 'UTF8';
fSpecificOptions.Values['UseUnicode'] := 'true';
fSpecificOptions.Values['CharLength'] := '2';
The legacy database codepage is WIN1252, for querying and showing data I'm doing the conversion of strings where is needed in order to show them right, and ATM my need is only to show info, but in the future I may store data back to the database, so I can change UTF8 to WIN1252 and comment the remaining lines but then on mORMot codebase updates I will lose those changes, Is there a way to configure that database options from code ?
Also on traditional client/server code I'm used to write code like this :
Transaction := TUniTransaction.Create(nil);
Try
Transaction.IsolationLevel := ilReadCommitted;
Transaction.DefaultConnection := DBConn;
Transaction.StartTransaction;
.
.
.
Transaction.Commit;
Finally
Transaction.Free;
End;
As I understand I don't need to manually create the transactions but I couldn't find a way to set the default Isolation level of the autocreated transactions, Is that even possible ?
And to finish this post, I'm not sure what is needed in order to safely manage transactions ( unit of work ), I think the answer is something like what is mentioned on https://synopse.info/files/html/Synopse … #TITLE_615 but since I'm not using the ORM I would like to hear what can you recommend for this use case.
That's all folks
Great I'll take a look at the subject you pointed out, I went to the the documentation before posting but is huge, remember what is simple for you is not so for others :-) I really appreciate the time and effort you take to help people like me.
Hi
I'm planning to use mormot for a little service using a legacy database, I was following your post Connecting to legacy databases and publishing a RESTful interface to it but I cannot make it run succesfully, at the start server I have something along this lines :
emptyModel := TSQLModel.Create([], ROOTSERVER);
DbConnection := TSQLDBUniDACConnectionProperties.Create(
TSQLDBUniDACConnectionProperties.URI(dFirebird,Server), Database, Username, Password);
StockServer := TSQLRestServerFullMemory.Create(emptyModel);
StockServer.ServiceDefine( TLegacyStockQuery.Create( DbConnection ), [ILegacyStockQuery]); <------ Error
Last line above throws the following error at runtime : TInterfaceFactory.GUID2TypeInfo({360A4C3A-E07A-4A9E-B0AB-FBBDABABAD4D}): Interface not registered - use TInterfaceFactory.RegisterInterfaces()
I'm testing on D2007, Windows 7, mORMot 1.18.3182 FTS3, I searched for downloadable code of the demo with no luck,
I have other projects using SQLite and TSQLRestServerDB never stumbled with this error.
Can you shed some light on this ?
Thank you
Thank you Arnaud, I'll take a look at that
I beg your pardon can I find that on the mORMot docs, or in any of the samples?
Hi everyone,
I'm doing some tests with FTS search, I need to have a mORMot server which will only be accesed as localhost from a Node.js application on the same physical/virtual machine, I already have the server working and doing FTS search like this :
http://localhost:8081/root?sql=SELECT RowId, item FROM ListSearch WHERE item MATCH :('peri*'):
All is working as expected but there are situations where the end user can do a search with a mispelled word e.g. changing a B with a V, or an accented spanish character e.g. i instead of í so for example if the search term would be dosi I would like the search result include also words with dosí and viceversa so I am looking for the Soundex/SoundexFR funcion mentioned on the docs, but I don't know how to ( and if ) the function can be included on a request as shown above.
Can anyone give any help with this ?
Hello everyone,
I finally found sometime to setup a linux VM and until now everything has been smooth ( fpcupdeluxe gave me big push here), now I want to make a simple daemon for querying static data I already have on a SQLite .db file, I post on this thread because it is sticked out here and I have one simple question related to linux servers.
Seems like I have to put these compiler directives on my lpr :
{$I Synopse.inc}
uses
...
{$I SynDprUses.inc}
...
Will that be enough ? Or there is any other directive I have to add
I'm working with current trunk ( Lazarus & FPC ) and the version mORMot which TestSQL3 reports is:
Using mORMot 1.18.3765 FTS3
Running on Linux-4.4.0-88-generic #111-Ubuntu SMP Thu Jul 20 09:32:39 UTC 2017
TSQLite3LibraryStatic 3.19.2 with internal MM
Generated with: Free Pascal 3.1.1 MOP 64 bit compiler
Thank you
Well this was kind of urgent and I know everybody here are pretty busy people, I passed the task to the existing TCP (non mormot) server and stored the user info on a legacy database, but STILL it would be nice if someone can enligthen me on how can one work with the SQLite database from SERVER code and in particular in this use case, I did some tests from client code and is pretty easy but not in this case, I couldn't use a TSQLRestclient in sessionCreated event because, well the TSQLRestclient needs to authenticate and that would fire sessionCreated again and that give us an ugly loop of events.
Regards
Hi,
I'm having a hard time trying to store/retrieve additinal user info, I have an TSQLHttpserver which is serving interface based services, and because I'm consuming data from another TCP server didn't have the need for storing retrieving info from SQLite, the groups and users are stored in a SQLite file to take advantage of the mORMot authentication, this database is populated at server startup using the ORM, everything is working well so far, but I have the need to store the date time (just an example) of user login, so I created an inherited TSQLAuthUser class :
TSQLMyAuthUser = class(TSQLAuthUser)
protected
FLastAccess : TDateTime;
published
property LastAccess : TDateTime read FLastAccess write FLastAccess;
end;
Then added:
class function TSessionmORMot.sessionCreated(Sender: TSQLRestServer;
Session: TAuthSession; Ctxt: TSQLRestServerURIContext): boolean;
var
myUser: TSQLMyAuthUser;
begin
myUser := TSQLMyAuthUser(Session.User);
myUser.LastAccess := Now;
TSqlRestserver(sender).Update(myUser);
Result := False;
end;
restServer.OnSessionCreate := TSessionmORMot.sessionCreated; // restServer is TSQLRestServerDB
Seemed to work fine, I can see populated the field LastAccess on the db file, but after two different users log in I have an error like this :
20170201 04062437 EXC ESecurityException {"Message":"Invalid TAuthSession.Create(TSQLRestRoutingREST,TSQLMyAuthUser)"} at 0054EB90 stack trace ...
Obviously that doesn't seem to be the right way, I was hoping that I would have access to the new field on my Interface based services with the following code ( recommendations are welcome ) :
var
context : TServiceRunningContext;
user : TSQLMyAuthUser;
theDate : TDateTime;
Begin
context := CurrentServiceContext;
user := TSQLMyAuthUser.Create(context.Request.Server, context.Request.SessionUser);
theDate := user.LastAccess;
End
So can a mORMot guru give me some advice on how to store safely the additional data and how to retrieve it from a service ?
Thank you all
@AOG
Many people are interested in the mORMot / FPC combi. If we help them, they will become mORMot users.
Many have difficulty with cross-compiling. If we help them, they will become mORMot/crossFPC users.
mORMot is now fully cross-platform. mORMot running on Linux64 is a MAJOR plus.
I am, please go on
@AB
We need some clear instructions, though, for beginners/reviewers of the FPC+Lazarus+mORMot solution.
A one-pass setup, with no manual modification whatsoever could be a big live changer!
Agreed, I'm ready to give it a shot if you need some feedback
@hnb
it is still FPC, NewPascal is just fork name with full credits for FPC and with full backward compatibility for the official FPC. We need to somehow distinguish between FPC and the FPC dedicated for our purposes.
Great! I like that too, compatibilty is dead serious, this is all very exciting I'll be watching the progress
Seems like there is a better future for SMS, time will tell:
https://jonlennartaasenden.wordpress.co … le-studio/
Merry christmas to you all !
Thank you Arnaud , I think we can go Windows first and following your advice I'll begin to research on the linux side of things later
Hi to all,
I know that support for Lazarus + FPC is not finished yet, but I'm looking more seriously to use FPC for my server code, and although I'm still coding 100% on Delphi + Windows I was wondering if I can have a server compiled with FPC to replace an existing interface based server which is serving https requests on a windows machine, so my questions are :
1. Can I serve https requests on Windows with a FPC + mORMot compiled binary ? I guess it has the same http.sys kernel-mode server support but I'm interested to hear experiences from others
2. Can I have a similar setup on Linux (I mean serving https requests) ?
3. If answer to number 2 is no, how far do you think is mORMot from doing same task on Linux ? ( I'll be just fine with windows, but I'm looking forward to linux server support )
Thank you
Feliz navidad para todos !! Y que el año próximo traiga lo mejor.