当前位置: 首页>>代码示例>>Python>>正文


Python Configurator.ptah_init_sql方法代码示例

本文整理汇总了Python中pyramid.config.Configurator.ptah_init_sql方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.ptah_init_sql方法的具体用法?Python Configurator.ptah_init_sql怎么用?Python Configurator.ptah_init_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.config.Configurator的用法示例。


在下文中一共展示了Configurator.ptah_init_sql方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ This is your application startup."""

    config = Configurator(settings=settings, session_factory=session_factory, authentication_policy=auth_policy)

    config.add_static_view("ptah_models", "ptah_models:static")

    # we love them routes
    config.add_route("root", "/")
    config.add_route("contact-us", "/contact-us.html")
    config.add_route("edit-links", "/links/{id}/edit", factory=models.factory, use_global_views=True)
    config.add_route("add-link", "/links/add.html")

    config.include("ptah")
    config.scan()

    # init ptah settings
    config.ptah_init_settings()

    # init sqlalchemy
    config.ptah_init_sql()

    # init ptah manage
    config.ptah_init_manage(managers=["*"], disable_modules=["rest", "introspect", "apps", "permissions", "settings"])

    config.commit()

    # Need to commit links to database manually.
    import transaction

    transaction.commit()

    return config.make_wsgi_app()
开发者ID:rainerwahnsinn,项目名称:examples,代码行数:35,代码来源:app.py

示例2: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ This is your application startup."""

    config = Configurator(settings=settings,
                          session_factory = session_factory,
                          authentication_policy = auth_policy)

    # init ptah settings
    config.ptah_init_settings()

    # init sqlalchemy engine
    config.ptah_init_sql()

    # configure ptah manage
    config.ptah_init_manage(
        managers = ['*'],
        disable_modules = ['rest', 'introspect', 'apps', 'permissions'])

    # we love them routes
    config.add_route('root', '/')
    config.add_route('login', '/login.html')
    config.add_route('logout', '/logout.html')

    # static assets
    config.add_static_view('ptah_simpleauth', 'ptah_simpleauth:static')

    config.scan()

    return config.make_wsgi_app()
开发者ID:cguardia,项目名称:examples,代码行数:31,代码来源:app.py

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ This is your application startup.
    """
    config = Configurator(root_factory=APP_FACTORY, settings=settings)

    # static assets
    config.add_static_view('ptah_minicms', 'ptah_minicms:static')

    config.scan()

    # init sqlalchemy engine
    config.ptah_init_sql()

    # init ptah settings
    config.ptah_init_settings()

    # enable rest api
    config.ptah_init_rest()

    # enable ptah manage
    config.ptah_init_manage()

    # populate database
    config.ptah_populate()

    return config.make_wsgi_app()
开发者ID:cguardia,项目名称:examples,代码行数:28,代码来源:app.py

示例4: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(init=True):
    import gevent.monkey
    gevent.monkey.patch_all()

    args = BackendCommand.parser.parse_args()

    # logging config
    def fileConfig(f, defaults):
        from logging.config import fileConfig
        return fileConfig(f, defaults, disable_existing_loggers = False)

    paster.setup_logging(args.config.split('#', 1)[0], fileConfig)

    # read settings
    parser = configparser.SafeConfigParser()
    parser.read((args.config,))
    settings = parser.items(configparser.DEFAULTSECT, vars={'here': './'})

    # run configuration
    config = Configurator(settings=settings)
    config.include('ptah')
    config.include('smxq')

    # ptah
    config.ptah_init_sql()
    config.ptah_init_settings()

    config.commit()

    # run command
    cmd = BackendCommand(args, config.registry, config)
    cmd.run()

    ptah.shutdown()
开发者ID:fafhrd91,项目名称:pyramid_smxq,代码行数:36,代码来源:start.py

示例5: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ This is your application startup.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_mailer')
    config.include('ptahcrowd')
    config.include('ptahcms')
    config.include('devapp')

    # init ptah settings
    config.ptah_init_settings()

    # init ptah sqlalchemy
    config.ptah_init_sql()

    # enable rest api
    config.ptah_init_rest()

    # enable ptah manage
    config.ptah_init_manage()

    # enable ptah manage
    config.ptah_populate()

    # set ptah mailer
    from pyramid_mailer.interfaces import IMailer
    mailer = config.registry.queryUtility(IMailer)
    config.ptah_init_mailer(mailer.direct_delivery)

    # We are not in a web request; we need to manually commit.
    transaction.commit()

    return config.make_wsgi_app()
开发者ID:ptahproject,项目名称:devel,代码行数:35,代码来源:__init__.py

示例6: test_ptahinit_sqla

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
    def test_ptahinit_sqla(self):
        config = Configurator(
            settings = {'sqlalchemy.url': 'sqlite://'})
        config.include('ptah')
        config.commit()

        config.ptah_init_sql()
        self.assertIsNotNone(ptah.get_base().metadata.bind)
开发者ID:djedproject,项目名称:ptah,代码行数:10,代码来源:test_init.py

示例7: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ This is your application startup."""
    
    config = Configurator(settings=settings,
                          session_factory = session_factory,
                          authentication_policy = auth_policy)
#    config.commit()
#    config.begin()

    # init ptah settings
    config.ptah_init_settings()

    # init sqlalchemy engine
    config.ptah_init_sql()

    # configure ptah manage
    config.ptah_init_manage(
        managers = ['*'],
        disable_modules = ['rest', 'introspect', 'apps', 'permissions'])


    # we love them routes
    config.add_route('root', '/')
    config.add_route('contact-us', '/contact-us.html')
    config.add_route('edit-objects', '/objects/{id}/edit',
                     factory=models.rackobject.factory, use_global_views=True)
    config.add_route('add-object', '/objects/add.html')
    config.add_route('login', '/login.html')
    config.add_route('logout', '/logout.html')

    # static assets
    config.add_static_view('rackptahbles', 'rackptahbles:static')

    config.scan()

    # create sql tables
    Base = ptah.get_base()
    Base.metadata.create_all()
    transaction.commit()

    # populate database
    config.commit()
    config.begin()

    Session = ptah.get_session()

    # admin user
    user = Session.query(User).first()
    if user is None:
        user = User('Admin', 'admin', '[email protected]', '12345')
        Session.add(user)

    #bootstrap data here, removed rackptahbles link population

    # Need to commit bootstrap data to database manually.
    transaction.commit()

    return config.make_wsgi_app()
开发者ID:bitmonk,项目名称:opsdash,代码行数:60,代码来源:app.py

示例8: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ Function which returns a configured Pyramid/Ptah WSIG Application """

    # Construct a db connection URL from 30Loops environment variables
    # pattern is postgresql+psycopg2://scott:[email protected]/mydatabase
    env = None
    try:
        f = open('/app/conf/environment.json')
        env = json.load(f)
        db_user = env["DB_USER"]
        db_name = env["DB_NAME"]
        db_host = env["DB_HOST"]
        db_pass = env["DB_PASSWORD"]
        db_url = "postgresql+psycopg2://"+db_user+":"+db_pass+"@"+db_host+"/"+dbname
        # Override the SQLAlchemy url from settings.ini
        settings['sqlalchemy.url']=db_url
    except:
        pass

    # Info: This is how Pyramid is configured.
    config = Configurator(settings=settings,
                          session_factory = session_factory,
                          authentication_policy = auth_policy)

    # Info: This includes packages which have Pyramid configuration
    config.include('ptah')
    config.commit()

    # Refer: Ptah: _Initialization_
    config.ptah_init_settings()

    # Refer: Ptah: _Initialization_
    config.ptah_init_sql()

    # enable ptah management
    config.ptah_init_manage(managers=('*',))

    # populate database
    config.ptah_populate()

    # Refer: Pyramid's _URL Dispatch_
    config.add_route('home', '/')

    # static assets
    config.add_static_view('_urbsly', 'urbsly:static')

    # Refer: Pyramid's _Configuration Decorations and Code Scanning_
    config.scan()

    return config.make_wsgi_app()
开发者ID:Urbsly,项目名称:30loops-ptah,代码行数:52,代码来源:app.py

示例9: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ Function which returns a configured Pyramid/Ptah WSIG Application """

    # Info: This is how Pyramid is configured.

    durl = os.environ.get("DATABASE_URL") #heroku

    if durl:
        settings['sqlalchemy.url']=durl
    else:
        logger.info('Did not find DATABASE_URL! You must issue, '
                    '$ heroku addons:add shared-database')

    config = Configurator(settings=settings,
                          session_factory = session_factory,
                          authentication_policy = auth_policy)

    # Info: This includes packages which have Pyramid configuration
    config.include('ptah')

    # Refer: Ptah: _Initialization_
    config.ptah_init_settings()

    # Refer: Ptah: _Initialization_
    config.ptah_init_sql()

    # enable ptah management
    config.ptah_init_manage(managers=('admin',))

    # populate database
    config.ptah_populate()

    # Refer: Pyramid's _URL Dispatch_
    config.add_route('home', '/')
    config.add_route('home2', '/home2')

    # static assets
    config.add_static_view('_herokuapp', 'herokuapp:static')

    # js protocols
    config.include('herokuapp.protocols')

    # add role
    Admin = ptah.Role('admin', 'Admin')
    Manager = ptah.Role('manager', 'Manager')

    # Refer: Pyramid's _Configuration Decorations and Code Scanning_
    config.scan()

    return config.make_wsgi_app()
开发者ID:ptahproject,项目名称:heroku-ptah,代码行数:52,代码来源:app.py

示例10: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):

    config = Configurator(settings=settings,
                          root_factory = models.blog_factory,
                          session_factory = session_factory,
                          authentication_policy = auth_policy)

    config.add_static_view('ptahto', 'ptahto:static')

    config.add_route('blog', '/')
    config.add_route('config', '/config.html')
    config.add_route('dashboard', '/dashboard.html')
    config.add_route('about', '/about.html')
    config.add_route('rss', '/rss')
    config.add_route('atom', '/atom')
    config.add_route('archive', '/posts')
    config.add_route('add-post', '/posts/add.html')
    config.add_route('view-post', '/posts/{id}',
                     factory=models.post_factory, use_global_views=True)
    config.add_route('edit-post', '/posts/{id}/edit.html',
                     factory=models.post_factory, use_global_views=True)
    config.add_route('categories', '/categories')
    config.add_route('add-category', '/categories/add.html')
    config.add_route('view-category', '/categories/{id}',
                     factory=models.category_factory, use_global_views=True)
    config.add_route('edit-category', '/categories/{id}/edit.html',
                     factory=models.category_factory, use_global_views=True)
    config.add_route('rss-category', '/categories/{id}/rss',
                     factory=models.category_factory, use_global_views=True)
    config.add_route('atom-category', '/categories/{id}/atom',
                     factory=models.category_factory, use_global_views=True)

    config.include('ptah')
    config.scan()

    config.ptah_init_settings()
    config.ptah_init_sql()
    
    config.ptah_init_manage(
        managers = ['*'],
        disable_modules = ['rest', 'introspect', 'apps', 'permissions', 'settings'])

    config.commit()

    import transaction
    transaction.commit()

    return config.make_wsgi_app()
开发者ID:cguardia,项目名称:ptahto,代码行数:50,代码来源:app.py

示例11: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ Function which returns a configured Pyramid/Ptah WSIG Application """

    # Info: This is how Pyramid is configured.

    # Originally for Heroku, needs to be modified for 30Loops
    #durl = os.environ.get("DATABASE_URL")
    #if durl:
    #    settings['sqlalchemy.url']=durl

    config = Configurator(settings=settings,
                          session_factory = session_factory,
                          authentication_policy = auth_policy)

    # Info: This includes packages which have Pyramid configuration
    config.include('ptah')
    config.commit()

    # Refer: Ptah: _Initialization_
    config.ptah_init_settings()

    # Refer: Ptah: _Initialization_
    config.ptah_init_sql()

    # enable ptah management
    config.ptah_init_manage(managers=('*',))

    # populate database
    config.ptah_populate()

    # Refer: Pyramid's _URL Dispatch_
    config.add_route('home', '/')

    # static assets
    config.add_static_view('_urbsly', 'urbsly:static')

    # Refer: Pyramid's _Configuration Decorations and Code Scanning_
    config.scan()

    return config.make_wsgi_app()
开发者ID:bastichelaar,项目名称:30loops-ptah,代码行数:42,代码来源:app.py

示例12: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ This is your application startup."""

    config = Configurator(settings=settings,
                          session_factory = session_factory)

    config.ptah_init_settings()
    config.ptah_init_sql()
    config.ptah_init_manage(managers = ['*'])
    config.ptah_populate()

    # enable jca
    config.register_jca_sm()

    # internal chat
    config.register_jca_component(
        'chat', 'ptah_chat:jca/', protocol = ChatProtocol)

    # we love them routes
    config.add_route('root', '/')

    config.scan()
    return config.make_wsgi_app()
开发者ID:cguardia,项目名称:examples,代码行数:25,代码来源:app.py

示例13: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ This is your application startup.
    """
    config = Configurator(root_factory=APP_FACTORY, settings=settings)

    # mustache templates
    config.add_mustache_bundle('ptah_ws', 'ptah_ws:jcatemplates/')
    
    # jca module
    config.register_amd_module('settings', 'ptah_ws:static/settings.js')

    # static assets
    config.add_static_view('ptah_ws', 'ptah_ws:static')
    config.scan()

    # init sqlalchemy engine
    config.ptah_init_sql()

    # init ptah settings
    config.ptah_init_settings()

    # enable rest api
    config.ptah_init_rest()

    # enable ptah manage
    config.ptah_init_manage()

    # populate database
    config.ptah_populate()

    # init sqlalchemy session
    import ptah_ws
    engine = sa.engine_from_config(settings, 'sqlalchemy.')
    ptah_ws._Session = sa.orm.sessionmaker(bind=engine)

    return config.make_wsgi_app()
开发者ID:cguardia,项目名称:examples,代码行数:38,代码来源:app.py

示例14: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
def main(global_config, **settings):
    """ themes app """
    APP_FACTORY = ptah.cms.ApplicationFactory(
        ThemeGallery, '/',
        policy=ThemeGalleryPolicy,
        name='themes', title='Ploud theme gallery')

    config = Configurator(root_factory=APP_FACTORY, settings=settings)
    config.include('ploud.themegallery')

    # init sqlalchemy engine
    config.ptah_init_sql()

    # init ptah settings
    config.ptah_init_settings()

    # enable rest api
    config.ptah_init_rest()

    # enable ptah manage
    config.ptah_init_manage(manager_role=Manager.id)

    # standalone layouts
    config.ptah_layout(
        'page', context=ThemeGallery, view=WorkspaceLayout,
        renderer='ploud.themegallery:templates/layout-page.pt')

    config.ptah_layout(
        'ptah-page', ThemeGallery, parent='page',
        renderer="ploud.themegallery:templates/layout-ptahpage.pt")

    # populate database
    config.commit()
    config.begin()

    # create sql tables
    Base = ptah.get_base()
    Base.metadata.create_all()

    # your application configuration
    ptah.auth_service.set_userid(ptah.SUPERUSER_URI)
    root = APP_FACTORY()

    # admin user
    from ptah_crowd import CrowdUser, CrowdFactory

    Session = ptah.get_session()
    user = Session.query(CrowdUser).first()
    if user is None:
        user = CrowdUser(title='Admin', login='admin', 
                         email='[email protected]',
                         password='{plain}12345')
        CrowdFactory().add(user)

    # give manager role to admin
    if user.__uri__ not in root.__local_roles__:
        root.__local_roles__[user.__uri__] = [Manager.id]

    # We are not in a web request; we need to manually commit.
    transaction.commit()

    return config.make_wsgi_app()
开发者ID:cleder,项目名称:ploud.themegallery,代码行数:64,代码来源:app.py

示例15: Configurator

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import ptah_init_sql [as 别名]
    # render form
    myform.update()
    return {'view': myform}


if __name__ == '__main__':
    """ ...

    """
    from pyramid.config import Configurator
    from pyramid.scripts.pserve import wsgiref_server_runner
    from pyramid.session import UnencryptedCookieSessionFactoryConfig

    config = Configurator(
        settings={'sqlalchemy.url': 'sqlite://'},
        session_factory=UnencryptedCookieSessionFactoryConfig('secret'))

    config.include('ptah')
    config.scan(__name__)

    config.ptah_init_sql()

    # create sql tables
    Base = ptah.get_base()
    Base.metadata.create_all()
    config.commit()

    app = config.make_wsgi_app()
    wsgiref_server_runner(app, {})
开发者ID:cguardia,项目名称:examples,代码行数:31,代码来源:form_imperative.py


注:本文中的pyramid.config.Configurator.ptah_init_sql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。