Are you using Pylons version 0.9.7?
Pylons allrady stable at 1.0 version.
You can use declarative with reflection direct in model/init.py outside of init_model function. Or you can separate model definitions in any other modules or packages.
model/schema.py
from YOURAPP.model.meta import Base # for declaration you models and reflection
from YOURAPP.model.meta import Session # for using sa session object
class Category(Base):
__tablename__ = 'category'
id = Column(Integer, primary_key=True)
name = Column(Unicode(70), index=True, unique=True)
def __unicode__(self):
return self.name
class Attribute(Base):
__tablename__ = 'attribute'
id = Column(Integer, primary_key=True)
name = Column(Unicode(70), index=True)
#Relation
category_id = Column(Integer, ForeignKey('category.id'))
category = relation(Category, backref=backref('attributes',
order_by=(name,))
def __unicode__(self):
return self.name
in model/init.py
from YOURAPP.model.schema import Category, Attribute