Re: [Lazarus] WebDataProvider's Factory Support

2010-10-24 Thread Michael Van Canneyt



On Sun, 24 Oct 2010, Leonardo M. Ramé wrote:


I'm trying to understand how does factory support works for
WebDataProvider.

Is this feature useful when the programmer don't want to add too many
WebDataProviders into the TFPWebProviderDataModule?.


yes.



It is possible to define the WebDataProviders in their own unit (by
code), then, in the TFPWebProviderDataModule register all providers with 
RegisterProvider,
to let the module know about them?.


You can do this.

How we work at my job is: create N datamodules with WebDataProviders, 
and at program startup, register all the datamodules in the factory.


There is exactly 1 TFPWebProviderDataModule which has the option set 
to check the factory registry. It is registered with URL /Providers.




If factory support's rationale is to avoid WebProviderDataModules full
of WebDataProviders, why not just divide the app with many
datamodules containing only some WebDataProviders?.


To have a single url. If you make many TFPWebProviderDataModules, they must all
be registered with their own URL. The factory system allows to have a single 
entry point.


All providers in my application are then accessible from
/Providers/ProviderName/Read
(and of course create/update/delete)

I created a Ext.data.Store descendent which has the URL and naming scheme
coded in so all I must do is
mystore = new WISA.ClientDataset ({
  ProviderName : 'MyData'
});
To access the data.

Michael.--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] WebDataProvider's Factory Support

2010-10-24 Thread Leonardo M . Ramé
On 2010-10-24 20:44:28 +0200, Michael Van Canneyt wrote:
 It is possible to define the WebDataProviders in their own unit (by
 code), then, in the TFPWebProviderDataModule register all providers with 
 RegisterProvider,
 to let the module know about them?.
 
 You can do this.
 
 How we work at my job is: create N datamodules with
 WebDataProviders, and at program startup, register all the
 datamodules in the factory.
 
 There is exactly 1 TFPWebProviderDataModule which has the option set
 to check the factory registry. It is registered with URL /Providers.

Ok, that way all datamodules (except the one that you mentioned) are just 
containers of WebDataProviders, until the moment where a request
needs one of them, then, the factory creates an instance of the required
one.

Much clear now, thanks Michael.

-- 
Leonardo M. Ramé
http://leonardorame.blogspot.com

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus