respond_tosupport
You can add a routing ruler.connect('/:controller/:action/:id.:format')at the bottom ofinitRoutes. Then you can userespond_tomethod like this:
self.respond_to(
html=lambda: self.render('<h1>Hello World</h1>'),
js=lambda: self.render(script='alert("hello, world")')
)
If 'http://example.com/foo/bar/12345.html' is requested, the controller will executelambda: self.render('<h1>Hello World</h1>'). While 'http://example.com/foo/bar/12345.js' is request, the client will receive a script content. They are the same action.Tell if a request is XHR
GAEO useX-Requested-Withheader to tell if a request is initiated by XMLHttpRequest object. You can tell that by seeing thatself._is_xhris True or False.rendermethod addscripttype
You can useself.render(script="alert('!')")to send clienttext/javascriptdata.REST methods
Now we route the REST methods to the main dispatcher, and you can useself._request_methodto get the request method (e.g., 'get', 'put', 'head', ...etc).
2008/09/27
GAEO Recent Updates
We had added these features (in 0.2 branch) recently:
Subscribe to:
Post Comments (Atom)
0 Comments:
Post a Comment