Pylons 0.9.7, SQLAlhemy 0.5.2
Вот модуль модели:
"""The application's model objects"""
import sqlalchemy as sa
from sqlalchemy import orm
from sqlalchemy import types
from pyfield.model import meta
def init_model(engine):
#global engine, Session
sm = orm.sessionmaker(autoflush=True, transactional=True, bind=engine)
meta.engine = engine
meta.Session = orm.scoped_session(sm)
#orm.mapper=
"""Call me before using any of the tables or classes in the model"""
## Reflected tables must be defined and mapped here
global reflected_insured
reflected_insured = sa.Table("INSURED", meta.metadata, autoload=True,
autoload_with= meta.engine)
orm.mapper(Insured, reflected_insured)
global reflected_managers
reflected_managers = sa.Table("MANAGERS", meta.metadata, autoload=True,
autoload_with = meta.engine)
orm.mapper(Managers, reflected_managers)
########################################################################
class Insured(object):
#----------------------------------------------------------------------
def __str(self):
return self.title
class Managers(object):
#----------------------------------------------------------------------
def __str(self):
return self.title
AS
BEGIN
IF (NEW.MID IS NULL) THEN
NEW.MID = GEN_ID(GEN_MANAGERS_ID,1); ##то-есть, имя генератора-GEN_MANAGERS_ID
END