Skip to content

Commit

Permalink
Added support for middelware sessions in wizard.
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Jan 27, 2025
1 parent bf213b3 commit 381a08b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
8 changes: 7 additions & 1 deletion ideexpert/DMVC.Expert.CodeGen.Commands.pas
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,13 @@ procedure TUnitWebModuleDeclarationCommand.ExecuteImplementation(
.AppendLine(' // fMVC.AddMiddleware(UseMemorySessionMiddleware);')
.AppendLine(' //')
.AppendLine(' // To use file based session uncomment the following line')
.AppendLine(' // fMVC.AddMiddleware(UseFileSessionMiddleware);');
.AppendLine(' // fMVC.AddMiddleware(UseFileSessionMiddleware);')
.AppendLine(' //')
.AppendLine(' // To use database based session uncomment the following lines,')
.AppendLine(' // configure you firedac db connection and create table dmvc_sessions')
.AppendLine(' // fMVC.AddMiddleware(TMVCActiveRecordMiddleware.Create(''firedac_con_def_name''));')
.AppendLine(' // fMVC.AddMiddleware(UseDatabaseSessionMiddleware);');


if Model.B[TConfigKey.webmodule_middleware_analytics] then
begin
Expand Down
1 change: 0 additions & 1 deletion samples/activerecord_showcase/MainFormU.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ object MainForm: TMainForm
TabOrder = 2
WantReturns = False
WordWrap = False
ExplicitHeight = 644
end
object btnRelations: TButton
Left = 8
Expand Down
4 changes: 2 additions & 2 deletions samples/activerecord_showcase/MainFormU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ interface
MVCFramework.Nullables,
MVCFramework.ActiveRecord,
MVCFramework.Logger,

System.Generics.Collections, System.Diagnostics;
System.Generics.Collections,
System.Diagnostics;

type
TMainForm = class(TForm)
Expand Down
4 changes: 2 additions & 2 deletions samples/htmx_website_with_templatepro/HelpersU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
interface

uses
System.Rtti;
System.Rtti, TemplatePro;

function MyHelper1(const Value: TValue; const Parameters: TArray<TFilterParameter>): TValue;
function MyHelper2(const Value: TValue; const Parameters: TArray<TFilterParameter>): TValue;
Expand All @@ -14,7 +14,7 @@ procedure TemplateProContextConfigure;
implementation

uses
TemplatePro, System.SysUtils;
System.SysUtils;


function MyHelper1(const Value: TValue; const Parameters: TArray<TFilterParameter>): TValue;
Expand Down
7 changes: 4 additions & 3 deletions sources/MVCFramework.ActiveRecord.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2853,13 +2853,14 @@ procedure TMVCActiveRecord.LoadByDataset(const aDataSet: TDataSet; const aOption

function TMVCActiveRecord.LoadByPK(const id: string; const aFieldType: TFieldType): Boolean;
var
SQL: string;
lSQL: string;
lDataSet: TDataSet;
begin
CheckAction(TMVCEntityAction.eaRetrieve);
SQL := SQLGenerator.CreateSelectByPKSQL(TableName, fTableMap.fMap,
lSQL := SQLGenerator.CreateSelectByPKSQL(TableName, fTableMap.fMap,
fTableMap.fPrimaryKeyFieldName, fTableMap.fPrimaryKeyOptions);
lDataSet := ExecQuery(SQL, [id], [aFieldType], GetConnection, True, False);
OnBeforeExecuteSQL(lSQL);
lDataSet := ExecQuery(lSQL, [id], [aFieldType], GetConnection, True, False);
try
Result := not lDataSet.Eof;
if Result then
Expand Down
19 changes: 4 additions & 15 deletions sources/MVCFramework.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2836,18 +2836,7 @@ function TMVCEngine.ExecuteAction(const ASender: TObject; const ARequest: TWebRe
lSelectedController.MVCControllerAfterCreate;
try
lHandled := False;
// if not ARequest.Accept.IsEmpty and (ARequest.Accept <> '*/*') then
// begin
// {if router allowed to reach this point, we try to adhere to
// the client preferred media type, so the response content type
// is by default the request accept header}
// lSelectedController.ContentType := BuildContentType(ARequest.Accept, '')
// end
// else
// begin
// {if client didn't specify an accept media type, we use the default content type}
lSelectedController.ContentType := BuildContentType(lResponseContentMediaType, lResponseContentCharset);
// end;
lActionFormalParams := lRouter.MethodToCall.GetParameters;
if (Length(lActionFormalParams) = 0) then
SetLength(lActualParams, 0)
Expand Down Expand Up @@ -3026,10 +3015,10 @@ function TMVCEngine.ExecuteAction(const ASender: TObject; const ARequest: TWebRe
HTTP_STATUS.ReasonStringFor(E.HTTPStatusCode),
E.DetailedMessage
], LOGGERPRO_TAG);
if lContext.SessionStarted then
begin
lContext.SessionStop;
end;
// if lContext.SessionStarted then
// begin
// lContext.SessionStop;
// end;
if Assigned(lSelectedController) then
begin
lSelectedController.ResponseStatus(E.HTTPStatusCode);
Expand Down

0 comments on commit 381a08b

Please sign in to comment.