On Fri, May 7, 2010 at 4:17 PM, Alexandre Conrad <[email protected]> wrote: > Hi list, > > Every time I create a controller, the generated test contains multiple > url(formatted_*, ...), e.g.: > > def test_edit_as_xml(self): > response = self.app.get(url('formatted_edit_article', id=1, > format='xml'), headers=self.headers) > > I was wondering what this was supposed to be used for. Request article > edition from an XML document? I don't have to implement this, but I > was just curious of the purpose of such test and how I should > interpret it.
The routes created by map.resource include a 'formatted_*' route alongside each regular route. The formatted routes have a '.FORMAT' suffix at the end of the URL; e.g., /articles/1234.xml, which you can access via the 'format' routing variable. This allows you to return the data in an alternate format. Of course, your action would have to support those formats or abort(404) if it doesn't. I don't know what editing in XML format would mean, or whether multi-formats makes sense for any action besides view. But if you had a web service that could accept either JSON or XML or other formats, it might work for that. -- Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
