On Wed, Feb 10, 2010 at 7:05 PM, Ryan Pusztai <rpusz...@gmail.com> wrote:
> Hi, > > I am using Orbit to write a web app and I have a very lengthy process of > importing 500+ files into a database and I wanted to give the user feedback > as this process continues. Is there a way to give the user updates? > > Even if it could be a "Please Wait..." message, then do the work, and then > redirect to a complete status page. I know that web:redirect() exists, but I > am having a tough time figuring out how to display a "please wait" message > then starting the actual lengthy process. > > Sorry if this is a silly question, but I just can't seem to get it working. > Ryan, Orbit does not buffer output by default, so you can't send a response to the client and continue processing. You have to use a special WSAPI rule to do that: ------- local function wsapi_action(wsapi_env, param) local request = wsapi.request.new(wsapi_env) local response = coroutine.wrap(function () coroutine.yield(my_waiting_html) ... do long operation ... coroutine.yield(rest of response) end) return 200, { ["Content-Type"] = "text/html" }, response end orbit_app:dispatch_wsapi(wsapi_action, "/foo/(%d+)") -------- WSAPI's request object is pretty similar to Orbit's web object, but slightly different. Please see the WSAPI docs. -- Fabio Mascarenhas > -- > Regards, > Ryan > > _______________________________________________ > Kepler-Project mailing list > Kepler-Project@lists.luaforge.net > http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project > http://www.keplerproject.org/ >
_______________________________________________ Kepler-Project mailing list Kepler-Project@lists.luaforge.net http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project http://www.keplerproject.org/