Exemplo n.º 1
0
def root_factory(request, t=transaction, g=get_connection,
                 evolve_packages=evolve_packages):
    """ A function which can be used as a Pyramid ``root_factory``.  It
    accepts a request and returns an instance of the ``Root`` content type."""
    # accepts "t", "g", and "evolve_packages" for unit testing purposes only
    conn = g(request)
    zodb_root = conn.root()
    if not 'app_root' in zodb_root:
        registry = request.registry
        app_root = registry.content.create('Root')
        zodb_root['app_root'] = app_root
        t.savepoint() # give app_root a _p_jar
        evolve_packages(
            registry,
            app_root,
            mark_all_current=True,
            )
        t.commit()
    return zodb_root['app_root']
Exemplo n.º 2
0
def root_factory(request,
                 t=transaction,
                 g=get_connection,
                 evolve_packages=evolve_packages):
    """ A function which can be used as a Pyramid ``root_factory``.  It
    accepts a request and returns an instance of the ``Root`` content type."""
    # accepts "t", "g", and "evolve_packages" for unit testing purposes only
    conn = g(request)
    zodb_root = conn.root()
    if not 'app_root' in zodb_root:
        registry = request.registry
        app_root = registry.content.create('Root')
        zodb_root['app_root'] = app_root
        t.savepoint()  # give app_root a _p_jar
        evolve_packages(
            registry,
            app_root,
            mark_all_current=True,
        )
        t.commit()
    return zodb_root['app_root']
Exemplo n.º 3
0
                set_db_version = int(v)
                if set_db_version < 0:
                    raise Exception
            except:
                usage('Bad version number %s' % v)

    setup_logging(config_uri)
    env = bootstrap(config_uri)
    root = env['root']
    registry = env['registry']

    try:
        results = evolve_packages(
            registry,
            root,
            package=package,
            set_db_version=set_db_version,
            latest=latest,
            )
    except Exception as e:
        usage(repr(e))

    for result in results:
        print 'Package %(package)s' % result
        print 'Code at software version %(sw_version)s' % result
        print 'Database at version %(db_version)s' % result
        print result['message']
        print ''

if __name__ == '__main__':
    main()