On Thu, Feb 11, 2010 at 12:39 PM, Ryan Pusztai <rpusz...@gmail.com> wrote:

> Hi Fabio,
>
> On Wed, Feb 10, 2010 at 4:20 PM, Fabio Mascarenhas <mascaren...@acm.org>wrote:
>>
>> 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.
>>
>
> Thanks for the quick response. It worked great, but I have been using
> htmlify and it does not work in the WSAPI dispatch. Is there any way to get
> it to work? Also is there a way to get the web object in the WSAPI dipatch?
> Thanks.
>

Why isn't htmlify working? You should be able to do
orbit.htmlify(wsapi_action), and then use things such as p{ "foo" } inside
wsapi_action to generate HTML (which you pass to coroutine.yield).

On your second question, on stock Orbit you can't do that, but if you expose
the make_web_object function (removing local) you can do this:

local web = orbit.make_web_object(orbit_app, wsapi_env)

I am sorry for this omission, I am going to expose a method in the
application objet to create a web object from a WSAPI environment.

-- 
> Regards,
> Ryan
>
>
--
Fabio Mascarenhas
_______________________________________________
Kepler-Project mailing list
Kepler-Project@lists.luaforge.net
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/

Reply via email to