#1 2015-03-08 08:27:04

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

MVC Web App, want to retrieve View files from DB, how?

Hi Arnaud,

Just checked out the '30 - MVC Server' example along with the MVC secctions in the document, I really like the convention over configuration concepts, which is time saving in coding the program.

I noticed that the view files (.html, .partial, .css, etc) are retrieved from a disk folder. What should I do if I want those files to be loaded from  BLOB fields of a DB? Thanks.


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

Offline

#2 2015-03-08 08:51:04

delphiancoder
Member
Registered: 2015-03-04
Posts: 11

Re: MVC Web App, want to retrieve View files from DB, how?

Hi,

during my tests I noted that changing the blog.css  file  (to reduce title and text sizes) nothing changed until kill and run the server runtime again. So I suppose the files are readed on startup and anything stay in ram.  reading from inside the database will add no speed,  I suppose.  Arnaud, is this correct ?

Offline

#3 2015-03-08 09:17:20

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

Re: MVC Web App, want to retrieve View files from DB, how?

delphiancoder wrote:

Hi,

during my tests I noted that changing the blog.css  file  (to reduce title and text sizes) nothing changed until kill and run the server runtime again. So I suppose the files are readed on startup and anything stay in ram.  reading from inside the database will add no speed,  I suppose.  Arnaud, is this correct ?

I did a quick look, yes, in TMVCViewsMustache.Create() the engine loads all the .html and .partials files into memory. I think it should offer an option to always load the view files from the real source.

I also suggest to add an event so that we can intercept the loading of the view files, something like OnLoadViewFileContent(aViewFileName: string: var aContent: string);


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

Offline

#4 2015-03-08 20:16:53

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

Re: MVC Web App, want to retrieve View files from DB, how?

This is a sample, so you can tune it for whatever you need!

Any suggestion is welcome.

Offline

#5 2015-03-09 15:37:25

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

Re: MVC Web App, want to retrieve View files from DB, how?

Re. the questions raised by delphiancoder (ie. not always loading files from disk), I suggest to add a boolean property to TMVCViewsMustache called CacheFiles, eg:

 TMVCViewsMustache.CacheFiles: Boolean

, to indicate if the files should be cached vs. always loading from the disk.


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

Offline

#6 2015-03-13 08:51:59

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

Re: MVC Web App, want to retrieve View files from DB, how?

AFAIR there is such an option already available.

Try to use the TMVCViewsMustacheParameters.FileTimestampMonitorAfterSeconds property to setup the template caching policy.

Offline

Board footer

Powered by FluxBB