diff options
| author | michael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2010-10-27 12:10:49 +0000 |
|---|---|---|
| committer | michael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2010-10-27 12:10:49 +0000 |
| commit | 24cbbaac267e0d4064b5335eb7be0858b19e9971 (patch) | |
| tree | 4256226c4d4bf4777d73ede1893e89487bcb9367 /packages/fcl-web/src/webdata/fpwebdata.pp | |
| parent | ed7a03f9cc2efdee2b185421508bd2c34bad99db (diff) | |
| download | fpc-24cbbaac267e0d4064b5335eb7be0858b19e9971.tar.gz | |
* Fixed batch processing, and multiple requests through 1 instance of an Adaptor
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@16231 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-web/src/webdata/fpwebdata.pp')
| -rw-r--r-- | packages/fcl-web/src/webdata/fpwebdata.pp | 77 |
1 files changed, 52 insertions, 25 deletions
diff --git a/packages/fcl-web/src/webdata/fpwebdata.pp b/packages/fcl-web/src/webdata/fpwebdata.pp index 9ccfb504c8..ea47199a9a 100644 --- a/packages/fcl-web/src/webdata/fpwebdata.pp +++ b/packages/fcl-web/src/webdata/fpwebdata.pp @@ -144,6 +144,9 @@ type procedure SetAdaptor(const AValue: TCustomWebDataInputAdaptor); procedure SetDataProvider(const AValue: TFPCustomWebDataProvider); Protected + Procedure StartBatch(ResponseContent : TStream); virtual; + Procedure NextBatchItem(ResponseContent : TStream); virtual; + Procedure EndBatch(ResponseContent : TStream); virtual; Function GetDataContentType : String; virtual; procedure DatasetToStream(Stream: TStream); virtual;abstract; Function CreateAdaptor(ARequest : TRequest) : TCustomWebdataInputAdaptor; virtual; @@ -869,6 +872,22 @@ begin FDataProvider.FreeNotification(Self); end; +procedure TCustomHTTPDataContentProducer.StartBatch(ResponseContent: TStream); +begin + // Do nothing +end; + +procedure TCustomHTTPDataContentProducer.NextBatchItem(ResponseContent: TStream + ); +begin + // do nothing +end; + +procedure TCustomHTTPDataContentProducer.EndBatch(ResponseContent: TStream); +begin + // do nothing +end; + function TCustomHTTPDataContentProducer.GetDataContentType: String; begin Result:=''; @@ -888,6 +907,7 @@ Var A : TCustomWebdataInputAdaptor; begin + {$ifdef wmdebug}SendDebugFmt('Request content %s',[ARequest.Content]);{$endif} B:=(Adaptor=Nil); if B then begin @@ -896,36 +916,43 @@ begin end; try try - While Adaptor.GetNextBatch do - begin - {$ifdef wmdebug}SendDebug('Starting batch Loop');{$endif} - Case Adaptor.Action of - wdaInsert : DoInsertRecord(Content); - wdaUpdate : begin - {$ifdef wmdebug}SendDebug('Aha1');{$endif} - DoUpdateRecord(Content); - {$ifdef wmdebug}SendDebug('Aha2');{$endif} - end; - wdaDelete : DoDeleteRecord(Content); - wdaRead : DoReadRecords(Content); - wdaUnknown : Raise EFPHTTPError.Create(SErrNoAction); - else - inherited DoGetContent(ARequest, Content,Handled); - end; - if (Adaptor.Action in [wdaInsert,wdaUpdate,wdaDelete,wdaRead]) then - Handled:=true; + Case Adaptor.Action of + wdaRead : DoReadRecords(Content); + wdaInsert, + wdaUpdate, + wdaDelete : + begin + {$ifdef wmdebug}SendDebug('Starting batch Loop');{$endif} + StartBatch(Content); + While Adaptor.GetNextBatch do + begin + {$ifdef wmdebug}SendDebug('Next batch item');{$endif} + NextBatchItem(Content); + Case Adaptor.Action of + wdaInsert : DoInsertRecord(Content); + wdaUpdate : DoUpdateRecord(Content); + wdaDelete : DoDeleteRecord(Content); + else + inherited DoGetContent(ARequest, Content,Handled); + end; + end; + EndBatch(Content); {$ifdef wmdebug}SendDebug('Ended batch Loop');{$endif} - end; - except - On E : Exception do - begin - DoExceptionToStream(E,Content); - Handled:=True; + end; + else + Raise EFPHTTPError.Create(SErrNoAction); end; + Handled:=true; + except + On E : Exception do + begin + DoExceptionToStream(E,Content); + Handled:=True; + end; end; finally If B then - FreeAndNil(A); + FreeAndNil(A); end; end; |
