2008/09/27

GAEO Recent Updates

We had added these features (in 0.2 branch) recently:

  1. respond_to support


    You can add a routing rule r.connect('/:controller/:action/:id.:format') at the bottom of initRoutes. Then you can use respond_to method 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 execute lambda: 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.

  2. Tell if a request is XHR


    GAEO use X-Requested-With header to tell if a request is initiated by XMLHttpRequest object. You can tell that by seeing that self._is_xhr is True or False.

  3. render method add script type


    You can use self.render(script="alert('!')") to send client text/javascript data.

  4. REST methods


    Now we route the REST methods to the main dispatcher, and you can use self._request_method to get the request method (e.g., 'get', 'put', 'head', ...etc).

0 Comments: