def includeme(config): """ Initialize the model for a Pyramid app. Activate this setup using ``config.include('Cosmetics.models')``. """ settings = config.get_settings() # use pyramid_tm to hook the transaction lifecycle to the request config.include('pyramid_tm') session_factory = get_session_factory(get_engine(settings)) config.registry['dbsession_factory'] = session_factory # make request.dbsession available for use in Pyramid config.add_request_method( # r.tm is the transaction manager used by pyramid_tm lambda r: get_tm_session(session_factory, r.tm), 'dbsession', reify=True) from pyramid.security import Everyone, Allow from pyramid_sacrud import PYRAMID_SACRUD_HOME, PYRAMID_SACRUD_VIEW acl = [ (Allow, Everyone, PYRAMID_SACRUD_HOME), (Allow, Everyone, PYRAMID_SACRUD_VIEW), (Allow, Everyone, 'test'), ] from ps_alchemy.resources import ListResource my_ps_group = ListResource(Group) my_ps_group.__acl__ = acl models = (('Test', [my_ps_group, User]), ('Test1', [Category, Unit])) config.include('ps_alchemy') config.include('pyramid_sacrud', route_prefix='admin') config.registry.settings['pyramid_sacrud.models'] = models