paster setup-app development.ini
- The MetaData object Pylons uses is defined in model/meta.py so is accessed here as meta.metadata whereas in the previous chapter it was defined in the same file so the examples just used metadata.
- Pylons generated the init_model() function when the project was created. It gets called after the engine has been created each time your application starts from config/environment.py to connect the model to the database.
Caution!
Pylons generates a project to use SQLAlchemy 0.4 but many users will want to use the newer SQLAlchemy 0.5 described in Chapter 7. They are very similar but the transactional=True argument to orm.sessionmaker() in init_model() is deprecated. Instead you should specify autocommit=False. This has exaclty the same behaviour but will not generate a deprecation warning.
change: model/meta.py # SQLAlchemy session manager. Updated by model.init_model() Session = scoped_session(sessionmaker(autoflush=True, autocommit=False))
#then offline in /c/downloads/python sudo easy_install -f . SQLAlchemy
cd /c/downloads/python/pylons-eggs sudo easy_install -zmaxd . easy_install -zmaxd . "SQLAlchemy >= 0.5, <=0.5.99"
forms are closely related to models
you'll need a way to persist the data.
if it's not tied to a specific directory of content, then it should probably be stored in a database of sorts to allow data lookup.
with pylons that probably means using sqlalchemy
if you didn't enable it in your project to begin with, you'll need to do so now following: | http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons
set up meta.py set up model
init_model in __init
configure database string in config (development.ini) sqlalchemy.url = sqlite:///%(here)s/jb-dev.sqlite
environment.py websetup.py
don't forget! paster setup-app development.ini
forms are closely related to models
you'll need a way to persist the data.
if it's not tied to a specific directory of content, then it should probably be stored in a database of sorts to allow data lookup.
with pylons that probably means using sqlalchemy
if you didn't enable it in your project to begin with, you'll need to do so now following: | http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons
set up meta.py set up model
init_model in __init
configure database string in config (development.ini) sqlalchemy.url = sqlite:///%(here)s/jb-dev.sqlite
environment.py websetup.py
don't forget! paster setup-app development.ini