Hi all,

Forgive me if this is slightly off topic, but I hope to get some  
feedback on the design of what I think is an improved version of the  
django-rest-interface. I have posted a gzipped archive of the code and  
an example application here:

http://code.google.com/p/django-rest-interface/issues/detail?id=26

Please see the file examples/views.py for a better idea of what I  
intend usage to look like.

All 'resources' derive from a single base class, including collections  
(see resources.py). A generalized Collection simply has the ability to  
delegate to child resources. A ModelCollection maps to a Django Model,  
whereas a ModelObjectResource maps to a model instance (models.py).  
SerDes (serdes.py) are used to serialize/deserialize models. It is  
straightforward to wrap a Django serializer with a SerDes, but writing  
your own allows you to create APIs that don't map exactly 1:1 with  
your models.

Authentication is implemented using a decorator syntax. It can be  
applied at the class level or at the individual CRUD level (method  
level takes precedence). There is also a deauthenticate decorator so  
that you can mark the class as having a certain level of  
authentication and relax this for particular methods.

Here is a very simple example of how you might create an API for a  
Publication model, using Django's builtin JSON serializer and HTTP  
basic authentication:

@authenticate(HttpBasicAuthentication())
class PublicationCollection(ModelCollection):
     allowed_methods = ('GET', 'POST')

Publications = PublicationCollection(Publication, JSONSerDes)


You could then put something like this in your urls.py:

urlpatterns = patterns('', (r'^publications(/(?P<id>.*))?$',  
Publications))


If anyone is interested, please take a look at the rest of the code, I  
am very curious to get feedback on its design and utility.

Thanks!
jared


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" 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/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to