views:

42

answers:

1

I have an existing Django application with a pretty typical model implementation that's backed by a database. My task is to change this model so that instead of fetching the information from a database, it now fetches it from a service (e.g., via HTTP). Because there is existing code which already makes use of this model, it would be nice to maintain the same model interface so that it continues to behave like a typical Django model.

This raises a few of questions:

  • Is it possible to do this without having to re-write the interface from scratch to make it look like Django's model interface? (This stackoverflow question would seem to suggest otherwise: http://stackoverflow.com/questions/1290891/django-mvc-pattern-for-non-database-driven-models)

  • Would writing a custom manager for this model be an appropriate approach (or have I misunderstood the role of the manager)?

  • Due to the service-backed nature of the new model, caching will be much more important than before. Is this something that should be implemented at the model level?

+3  A: 

Have a look at django-roa. From the sound of it, it might be exactly what you are looking for.

piquadrat
This is really neat, and I hadn't seen it before. Unfortunately, the service in question isn't a RESTful one, and I think I'll need the ability to use custom code to perform the work usually done by the database.Still, where one has a RESTful service they can attach their models to, this is pretty nice.
Michael Wehner
As fate would have it, I no longer need to have a non-database model in real life. As a consequence, this is a much better answer to the question I would rather have been asking anyway. Thanks!
Michael Wehner