Question

I'm looking for the most graceful way of taking a non-web project based on either SQLObject or SQLAlchemy and overlay it with a decent web-framework.

I've looked at Turbogears, and even though it looks like something I could use, the models seems to have to be defined inside the Turbogears framework. I want the core functionality (models, code) and the presenting layer (turgbogears, ?) to be separated.

I need something that can take models from my already existing codebase and help presenting data without too much hassle.

Was it helpful?

Solution

For this kind of thing you might have a look at Pyramid. It is very flexible in that it doesn't enforce any particular group of components (template, database engine, etc.). You could use it with either SqlObject or SqlAlchemy - it's up to you to configure it to your needs. Fortunately it is also very well documented.

There are some Pyramid recipes for setting up SqlAlchemy as well as a couple of frameworks built on top of Pyramid that add preconfigured defaults that include SqlAlchemy: Akhet and Kufu.

OTHER TIPS

Most web frameworks try to be a one-stop-shop for all of your web-application needs, to varying degrees of tight or loose coupling. That said, python is python, and the web framework can't do much to stop you from using it in your own way. Just pick the framework that suits your needs and use your existing libraries where you need them.

A more concrete answer will require a more concrete question of the form:

"How do I do X with my existing Y in Z framework? This is what happens when I tried: [error message here]"

actually there is a simple way to do that in turbogears. there is no problem rebinding table to existing sqlalchemy mode with autoload:true - like shown here. and moving your methods and code into the controller/model isn't such a hassle and give you all of turbogears power and actually you could also include something like the following code in config/app_cfg.py:

from mycode import mymethod
base_config.call_on_startup = [mymethod]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top