3

I'm not a Python developer, but I work with Python developers.

The scenario is the following: I have been asked to implement part of a system that integrates with a Python framework. I then agreed with the other team to develop my part in Java and provide full support to them implementing REST bindings. So I implemented a webapp in Java using Spring MVC and Hibernate. I can't go in detail but the design contract resembles the following:

The Python framework invokes a REST API with special authentication and authorization headers. The Spring MVC controller uses interceptor to perform authentication and authorization based on such HTTP headers, then gets invoked. The controller itself uses a path variable and two optional GET parameters to determine the type of object being accessed and the timestamp range

/api/{datatype}?[starttime=AAA]&[endtime=BBB]

Using a proper switch statement I choose the right Hibernate repository to query with these parameters and return an object (mapped to a table) that is translated to JSON by Jackson mapper for Spring MVC.

As a system integrator, I'd tell the guys to simply form legal HTTP requests to my component running on Tomcat and decode JSON (which is designed according to THEIR database model).

Instead the guys asked me to translate all the thing to Python. Apart being totally inexperienced in Python (I could barely write a console application that computes binomial coefficient, just not to implement yet another hello world or simple calculator), I guess that in Python no such thing as Hibernate, Spring and Jackson exist.

So, let's go to the question. Are there in Python any frameworks that allow me to...?

  • Easily create REST APIs with little code (Django????)
  • Easily intercept existing REST APIs and modularize the HTTP pipeline properly, i.e. doing authentication out-of-api-code, post-processing output stream, etc. through a mechanism similar to interceptors (I have seen something like that in their code base for authentication... we may mark this as solved)
  • Perform Dependency Injection. When switching between dev, staging, production, I currently change the class implementing an interface invoked by business code
  • Map objects to relations, such as Hibernate. That's currently my darkest point. I don't think there is any ORM in Python
  • Map objects to JSON (I know it's feasible, they already do in their codebase)

I won't post sample code believing it useless. I have tried to post a question as a general problem, not digging into specifics.

usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305
  • 2
    +1 for a well-constructed and written question, but it ***is*** not constructive according to the site guidelines. If you are looking at Django, note that it ***does*** include an ORM mapping layer. In addition there are other ORM mapping tools for Python. Read [this](http://stackoverflow.com/questions/53428/what-are-some-good-python-orm-solutions) SO post. – Perception Feb 26 '13 at 16:10
  • But that mostly answers the question! +2 – usr-local-ΕΨΗΕΛΩΝ Feb 26 '13 at 16:29

0 Answers0