Latest work...

27 views
Skip to first unread message

Tom Christie

unread,
Apr 26, 2011, 5:19:24 PM4/26/11
to django-res...@googlegroups.com
I've been working on a bit of refactoring which I'm planning on checking to the dev fork fairly soon.
(Not had a chance to check it in yet, since I was using the time on the long haul flights - no internet)
It's a reasonably big piece of work - finally tidies up some of the bits and pieces...

* allowed_methods and anon_allowed_methods are now defunct.  if a method is defined, it's available.
* 'permissions' attribute on the resource is now used to provide generic permissions checking.  These look like (eg) IsAuthenticatedUser, IsAdminUser, ReadOnly, ValidOAuthToken, Throttle.
* the handler functions no longer take the 'auth' and (for PUT/POST) 'content' arguments.  instead use self.auth and self.CONTENT.
  advantages:
    same pattern as existing CBVs.
    will integrate more easily with some existing Django CBV stuff if you're just using mixin classes rather than Resource/ModelResouce.
    request parsing gets deferred, until it is required if at all.
    requests other than POST and PUT can support request bodies (atypical, but valid HTTP nonetheless)
    logic is looking much cleaner.
* 'validators' attribute on the resource is now used for input validation.  Currently there's FormValidation and ModelFormValidation.  It fits the pattern of the other customizable behavior more closely.
* Mixins have been refactored nicely, now there's just RequestMixin, ResponseMixin and AuthMixin.
* Resource.dispatch is now looking nice and simple and much closer to django's existing View.dispatch

I've also made some minor changes to the language used:

* ResponseException becomes ErrorResponse.
* I _think_ 'emitters' should become 'renderers' - 'emitters' is a Piston thing, 'renderers' is closer to existing Django language.
* 'authenticators' may just become 'authentication' - it feels like invented language otherwise.

Basically trying to get everything nice and clean, make everything as Django-esque as possible, and importantly, trying to use CBVs in a closer way to how Django uses them.  I actually didn't realise how close 1.3's CBVs where to release when I started REST framework, so it's been a bit of a mission trying to get in line, but I think this is one of the last big hurdles.

Be great if you folk could kick the tires a bit once I get it checked in...

Really want to try to thrash it out quickly and (finally) release a pypi update.

Also I've made a start on stuff like throttling, and some permissions stuff, and I've got a few bits of work on the table if anyone's up for some contributing right now :) ??

  t.

Tom Christie

unread,
Apr 28, 2011, 12:41:49 PM4/28/11
to django-res...@googlegroups.com
Alrighty, checked in to a fork:


I've had some useful feedback from Marko already, but if anyone else wants to take an early look and chime in the right thing to do would be:

1) Take a look-see through mixins.py and resource.py and see if you think it's an improvement.  If not - why not - what do you and don't you like?
2) Try porting your existing project to this fork, bearing in mind the changes I've mentioned.  Should be easy enough.

I think it's not quite ready to go just yet - I want to try to get any backwards incompatible stuff, getting the language right etc... all sorted out as much as possible for the next release, so that it's not something that drags out over several releases.

Reply all
Reply to author
Forward
0 new messages