TG Cache
Very useful cache decorator for TG1.
Not sure how I missed this one, but it’s definitely worth a look for anybody trying to scale a TG1 application.
Thinking about programming in new ways
Very useful cache decorator for TG1.
Not sure how I missed this one, but it’s definitely worth a look for anybody trying to scale a TG1 application.
TurboGears has used a tree of controller objects to do URL dispatch since 1.0. Which is nice and easy to understand, and makes getting started very quick. But, it wasn’t always apparent how you should use it to do RESTful dispatch, since the HTTP verbs all ended up going to the same controller method.
You could dispatch within that method, but that never felt totally clean to me. And I’ve been thinking and talking about better ways to do this. The good news is that Rick Copland just “made it happen” after a conversation in atlanta last week.
Using his trick you can write code like this:
class Root(controllers.RootController):
class person(RestMethod):
@expose('json')
def get(self, **kw):
#...do stuff...
return dict(method='GET', args=kw)
@expose('json')
def post(self, **kw):
#...do stuff...
return dict(method='POST', args=kw)
# NOT exposed
def delete(self, **kw):
return dict(method='DELETE', args=kw)
And then HTTP GET and POST verbs will be routed to their respective methods. This makes working with RESTFul api’s easier. And on that front I’m very much looking forward to Dojo 1.2 which has all of kinds of restful json data store goodness.
Hopefully Rick’s recipe can find it’s way into the 1.x core code somewhere so that it’s even easier to do. But for now a couple dozen lines of code gives you everything you need for RESTful goodness.
Looks like the TG 1.x team has been doing good things. CherryPy 3 is support is a very, very good to hear that it’s been integrated into TG1, because this sets the stage for a much longer support cycle for TG1.
CherryPy 3 is a more solid base to work with, and it’s easier to invision supporting it for several years than it was with CherryPy 2.x. And the test-refactoring work that has gone into making this happen is a huge benefit as well, because you will be able to write application level tests that work in tg 1.5 and will still work in 2.0, easing that migration path.
Florent Aide may be on vacation, but things are still moving forward very quickly on the 1.5 front. I’m looking forward to seeing a release with all this great stuff in it.