mORMot and Open Source friends
Check-in [8adc764592]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{770} added optional aServerRoot parameter for the GetModel() and GetClient() functions, as generated by our cross-platform wrappers for Delphi CrossPlatform and SmartMobileStudio
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8adc764592500a9fc78ad834bdba1d64aca30efc
User & Date: ab 2015-01-29 13:54:03
References
2015-02-27
11:43
{989} fixed compilation issue of generated wrappers for SmartMobileStudio introduced by [8adc764592] check-in: ca1bad49bd user: ab tags: trunk
Context
2015-01-29
14:39
{771} updated documentation about "netsh http" command line tool use check-in: 914731dfe2 user: ab tags: trunk
13:54
{770} added optional aServerRoot parameter for the GetModel() and GetClient() functions, as generated by our cross-platform wrappers for Delphi CrossPlatform and SmartMobileStudio check-in: 8adc764592 user: ab tags: trunk
2015-01-28
18:40
{769} fixed JSON parsing of null variant properties in JSONToObject() serialization function check-in: d3adbc9a70 user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to CrossPlatform/templates/CrossPlatform.pas.mustache.

116
117
118
119
120
121
122


123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
{{/methods}}
  end;

{{/soa.services}}
const
  /// the server port{{#uri}}, corresponding to http://{{host}}{{/uri}}
  SERVER_PORT = {{port}};




/// return the database Model corresponding to this server
function GetModel: TSQLModel;

/// create a TSQLRestClientHTTP instance and connect to the server
// - it will use by default port {{port}}
{{#authClass}}
// - secure connection will be established via {{.}}
// with the supplied credentials - on connection or authentication error,
// this function will raise a corresponding exception
{{/authClass}}
function GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
  aServerPort: integer=SERVER_PORT): TSQLRestClientHTTP;

{{#withHelpers}}
// publish some low-level helpers for variant conversion
// - used internally: you should not need those functions in your end-user code
{{#enumerates}}
function Variant2{{name}}(const _variant: variant): {{name}};
{{/enumerates}}
................................................................................
    res.AddValue({{#toVariant}}{{toVariant}}{{/toVariant}}(_array[i]));
  result := variant(res);
end;

{{/arrays}}
{{/withArrays}}

function GetModel: TSQLModel;
begin
  result := TSQLModel.Create([{{#orm}}{{className}}{{comma}}{{/orm}}],'{{root}}');
end;

function GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
  aServerPort: integer): TSQLRestClientHTTP;
begin
  result := TSQLRestClientHTTP.Create(aServerAddress,aServerPort,GetModel,true); // aOwnModel=true
  try
    if (not result.Connect) or (result.ServerTimeStamp=0) then
      raise ERestException.CreateFmt('Impossible to connect to %s:%d server',
        [aServerAddress,aServerPort]);
{{#authClass}}
    if not result.SetUser({{.}},aUserName,aPassword) then 
      raise ERestException.CreateFmt('%s:%d server rejected "%s" credentials',






>
>



|


|






|







 







|

|



|

|







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
{{/methods}}
  end;

{{/soa.services}}
const
  /// the server port{{#uri}}, corresponding to http://{{host}}{{/uri}}
  SERVER_PORT = {{port}};
  /// the server model root name{{#uri}}, corresponding to http://{{host}}{{/uri}}
  SERVER_ROOT = '{{root}}';


/// return the database Model corresponding to this server
function GetModel(const aRoot: string=SERVER_ROOT): TSQLModel;

/// create a TSQLRestClientHTTP instance and connect to the server
// - it will use by default port {{port}} over root '{{root}}'
{{#authClass}}
// - secure connection will be established via {{.}}
// with the supplied credentials - on connection or authentication error,
// this function will raise a corresponding exception
{{/authClass}}
function GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
  aServerPort: integer=SERVER_PORT; const aServerRoot: string=SERVER_ROOT): TSQLRestClientHTTP;

{{#withHelpers}}
// publish some low-level helpers for variant conversion
// - used internally: you should not need those functions in your end-user code
{{#enumerates}}
function Variant2{{name}}(const _variant: variant): {{name}};
{{/enumerates}}
................................................................................
    res.AddValue({{#toVariant}}{{toVariant}}{{/toVariant}}(_array[i]));
  result := variant(res);
end;

{{/arrays}}
{{/withArrays}}

function GetModel(const aRoot: string): TSQLModel;
begin
  result := TSQLModel.Create([{{#orm}}{{className}}{{comma}}{{/orm}}],aRoot);
end;

function GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
  aServerPort: integer; const aServerRoot: string): TSQLRestClientHTTP;
begin
  result := TSQLRestClientHTTP.Create(aServerAddress,aServerPort,GetModel(aServerRoot),true); // aOwnModel=true
  try
    if (not result.Connect) or (result.ServerTimeStamp=0) then
      raise ERestException.CreateFmt('Impossible to connect to %s:%d server',
        [aServerAddress,aServerPort]);
{{#authClass}}
    if not result.SetUser({{.}},aUserName,aPassword) then 
      raise ERestException.CreateFmt('%s:%d server rejected "%s" credentials',

Changes to CrossPlatform/templates/SmartMobileStudio.pas.mustache.

106
107
108
109
110
111
112


113
114
115
116
117
118
119
120
121
122
123
124
125
126

127
128
129
130
131
132
133
...
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
  end;

{{/soa.services}}

const
  /// the server port{{#uri}}, corresponding to http://{{host}}{{/uri}}
  SERVER_PORT = {{port}};




/// return the database Model corresponding to this server
function GetModel: TSQLModel;

/// create a TSQLRestClientHTTP instance and connect to the server
// - it will use by default port {{port}}
{{#authClass}}
// - secure connection will be established via {{.}}
// with the supplied credentials
{{/authClass}}
// - request will be asynchronous, and trigger onSuccess or onError event
procedure GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
  onSuccess, onError: TSQLRestEvent; aServerPort: integer=SERVER_PORT);


{{#withHelpers}}
// publish some low-level helpers for variant conversion
// - used internally: you should not need those functions in your end-user code
{{#enumerates}}
function Variant2{{name}}(const _variant: variant): {{name}};
{{/enumerates}}
................................................................................
  {{/fields}}
  end;
end;

{{/isInMormotPas}}
{{/orm}}

function GetModel: TSQLModel;
begin
  result := TSQLModel.Create([{{#orm}}{{className}}{{comma}}{{/orm}}],'{{root}}');
end;

procedure GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
  onSuccess, onError: TSQLRestEvent; aServerPort: integer);
begin
  var client := TSQLRestClientHTTP.Create(aServerAddress,aServerPort,GetModel,true);
  client.Connect(
  lambda
    try
      if client.ServerTimeStamp=0 then begin
        if Assigned(onError) then
          onError(client);
        exit;






>
>



|


|






|
>







 







|

|



|

|







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
...
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
  end;

{{/soa.services}}

const
  /// the server port{{#uri}}, corresponding to http://{{host}}{{/uri}}
  SERVER_PORT = {{port}};
  /// the server model root name{{#uri}}, corresponding to http://{{host}}{{/uri}}
  SERVER_ROOT = '{{root}}';


/// return the database Model corresponding to this server
function GetModel(const aRoot: string=SERVER_ROOT): TSQLModel;

/// create a TSQLRestClientHTTP instance and connect to the server
// - it will use by default port {{port}} over root '{{root}}'
{{#authClass}}
// - secure connection will be established via {{.}}
// with the supplied credentials
{{/authClass}}
// - request will be asynchronous, and trigger onSuccess or onError event
procedure GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
  onSuccess, onError: TSQLRestEvent;
  aServerPort: integer=SERVER_PORT; const aServerRoot: string=SERVER_ROOT);

{{#withHelpers}}
// publish some low-level helpers for variant conversion
// - used internally: you should not need those functions in your end-user code
{{#enumerates}}
function Variant2{{name}}(const _variant: variant): {{name}};
{{/enumerates}}
................................................................................
  {{/fields}}
  end;
end;

{{/isInMormotPas}}
{{/orm}}

function GetModel(const aRoot: string): TSQLModel;
begin
  result := TSQLModel.Create([{{#orm}}{{className}}{{comma}}{{/orm}}],aRoot);
end;

procedure GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
  onSuccess, onError: TSQLRestEvent; aServerPort: integer; const aServerRoot: string);
begin
  var client := TSQLRestClientHTTP.Create(aServerAddress,aServerPort,GetModel(aServerRoot),true);
  client.Connect(
  lambda
    try
      if client.ServerTimeStamp=0 then begin
        if Assigned(onError) then
          onError(client);
        exit;

Changes to SynopseCommit.inc.

1
'1.18.769'
|
1
'1.18.770'