#1 2015-07-14 13:51:21

willo
Member
From: Cape Town, South Africa
Registered: 2014-11-15
Posts: 67
Website

Taming the Mormot

Hi guys,

I've decided to blog my experiences and bits of knowledge I pick up as 'n explore the mORMot landscape here https://tamingthemormot.wordpress.com/ . Hopefully it will help someone else too. Comments welcome!

Willo

Offline

#2 2015-07-14 15:19:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: Taming the Mormot

Wow!
This is just great!

Some users were asking for such tricks.

Thanks a lot!

Continue sharing such good information!
smile

Perhaps we may publish some source code.
A dedicated folder in our "third party" sample official source code tree is ready for you, if you wish!

Offline

#3 2015-07-15 04:54:17

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Taming the Mormot

I wish you have done this before I started using mORMot big_smile


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2015-07-15 06:45:01

willo
Member
From: Cape Town, South Africa
Registered: 2014-11-15
Posts: 67
Website

Re: Taming the Mormot

Thanks guys!

Offline

#5 2015-07-15 07:38:59

cypriotcalm
Member
Registered: 2015-02-18
Posts: 122

Re: Taming the Mormot

willo wrote:

Thanks guys!

Many thanks to you. I can see that my approaches to use the framework are right, or go in the same direction! :-D *feeling happy*

Offline

#6 2015-07-15 11:27:30

willo
Member
From: Cape Town, South Africa
Registered: 2014-11-15
Posts: 67
Website

Re: Taming the Mormot

I'm still exploring, so I reserve the right to retract anything I've published! big_smile I'm sure it won't get to that, but I AM sure I will want to revisit some of my earlier examples later, as I gain experience, to make adjustments.

Offline

#7 2015-07-16 06:41:39

willo
Member
From: Cape Town, South Africa
Registered: 2014-11-15
Posts: 67
Website

Re: Taming the Mormot

Ab,

I'm thinking I should take you up on your offer of publishing the sample projects in a dedicated folder under your "third party" source code tree. How would I go about doing that?

Offline

#8 2015-07-16 08:06:39

Rob
Member
Registered: 2014-07-30
Posts: 8

Re: Taming the Mormot

Nice !

Offline

#9 2015-07-16 15:15:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: Taming the Mormot

@Willo

You can send me the source code at webcontact01 at synopse dot info and I will publish them.
Or just publish them on github or on a dropbox zip file, and put a link in the forum.

Offline

#10 2015-07-17 06:27:03

willo
Member
From: Cape Town, South Africa
Registered: 2014-11-15
Posts: 67
Website

Re: Taming the Mormot

Thanks Ab, I'll probably go with a Git Pull request.

Next article is trying to uncover the mysteries of DI in mORMot. I might need some assistance in this regard, but will shout when I give up wink

Offline

#11 2015-07-20 10:44:35

willo
Member
From: Cape Town, South Africa
Registered: 2014-11-15
Posts: 67
Website

Re: Taming the Mormot

Thanks for your comments on my DI article, Ab. I fixed it up now.

Offline

#12 2018-05-30 19:00:42

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 129

Re: Taming the Mormot

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

Offline

#13 2018-05-30 21:08:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: Taming the Mormot

This blog article is not complete, in fact.
use TInterfaceFactory.RegisterInterfaces seems pretty clear: you need to call this first to register your interface.

As simple search in the documentation would have given to you the needed information:
https://synopse.info/files/html/Synopse … l#TITL_141

Offline

#14 2018-05-30 23:18:29

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 129

Re: Taming the Mormot

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.

Offline

#15 2018-05-31 10:00:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: Taming the Mormot

Yes, I now, it takes some efforts to tame the mORMot!
smile

Offline

#16 2018-06-02 17:09:56

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 129

Re: Taming the Mormot

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  wink

Offline

Board footer

Powered by FluxBB