I'm thinking about rewriting a rather large part of a web site in Python (turbo gears is profiled as the candidate).
I have almost 10 years of PHP dev in my back, and am fairly confident in it, but I too know exactly how it interacts with the web server.
It's not the case with python as a web language though.
The application I talk about is a web page screenshot service.
As I said, my application is already in Python, but is running in the form of a shell app that is called from PHP.
What I'd like to do, is to couple it with the Postgresql database, to let python handle the caching and statistics update, rather than doing them in PHP.
Right now, the schema is
° A user call a specific page
° Php parse the parameters, and verify them
° If a user hash is passed, a lookup upon the DB to determine what service is available to the user is done
° As a plus, a user can filter which urls are allowed to call the service, so a reverse DNS check is done to verify that
° The Python app is called and save it's result in a ramdisk (for performances)
° The Php takes back what have been outputed by python, ad serves it back.
In my mind, for the moment (I'm still thinking about it), the state I'd like to have is either:
Code:
Scenarii 1:
PHP:
- Receive the request
- Parse the parameters
- Check if the webshot is in the cache
- Put the request in a queue
or
- Serve the image from the cache & update user stats
Python
- Get the job from queue
- launche the service
- Save the result in the cache
- Update the user usage stats
It would be the simple, as only a small part would be moved from PHP tp Python, but terrible as many object I have in PHP would be ported in python, and they would overlap each other.
I'm not very fond of that idea...
The scenari 2 would be:
Ditch PHP completely, and use Python with turbo charged for the frontend.
I have to admit that I tend to scenarii 2, if only just for curiosity.
But, I don't really see how to integrate my existing application into a turbo charged web site.
Right now, my python application save a file in a specifed path.
I could transform it to return a PIL image resource.
It's the more flexible solution I see for the moment.
I have to admit that I never was fond of any framework.
All those I've ever approached, I ditched them because they where getting more in my way than helping me.
And I wonder if this turbo charged one is not going to end up the same.
ORM: One thing I'm really not fond of.
What can I say? I love SQL. It's as simple as that.
Writing queries is not
that hard, and I frankly don't understand the hype after linq or similar solutions.
If you need to fine tune your application, you need to control it from start to end. Abstraction is about simplifying the dev. job, not optimizing the code.
And as far as I see it, turbo gears (and django) seems to force me to go through a model definition that will create my database structure and relations at compilation time.
This is not what I would call a "plus"
Plus, the templating engine looks terrible...
I'm used to XML+XSL for the front-end separation, and mixing HTML with Python code looks just like a bit jump backward to me.
So, does anyone here have ever faced something similar ?
Does anyone here have made the jump from PHP or any other language/framework to Python ?