예제 #1
0
파일: fields.py 프로젝트: runyaga/ptah
    def update(self):
        data = []

        fields = ptah.get_cfg_storage(FIELD_ID)
        previews = ptah.get_cfg_storage(PREVIEW_ID)

        for name, cls in fields.items():
            data.append({'name': name,
                         'doc': cls.__doc__,
                         'preview': previews.get(cls)})

        self.fields = sorted(data, key = lambda item: item['name'])
예제 #2
0
파일: manage.py 프로젝트: djedproject/ptah
    def __getitem__(self, key):
        if self.cfg['enable_modules']:
            if key in self.cfg['enable_modules']:
                mod = ptah.get_cfg_storage(MANAGE_ID).get(key)
                if mod is not None:
                    return mod(self, self.request)

        elif key not in self.cfg['disable_modules']:
            mod = ptah.get_cfg_storage(MANAGE_ID).get(key)
            if mod is not None:
                return mod(self, self.request)

        raise KeyError(key)
예제 #3
0
파일: manage.py 프로젝트: sidloki/ptah
    def __getitem__(self, key):
        if self.cfg['enable_modules']:
            if key in self.cfg['enable_modules']:
                mod = ptah.get_cfg_storage(MANAGE_ID).get(key)
                if mod is not None:
                    return mod(self, self.request)

        elif key not in self.cfg['disable_modules']:
            mod = ptah.get_cfg_storage(MANAGE_ID).get(key)
            if mod is not None:
                return mod(self, self.request)

        raise KeyError(key)
예제 #4
0
파일: fields.py 프로젝트: runyaga/ptah
    def update(self):
        data = []

        fields = ptah.get_cfg_storage(FIELD_ID)
        previews = ptah.get_cfg_storage(PREVIEW_ID)

        for name, cls in fields.items():
            data.append({
                'name': name,
                'doc': cls.__doc__,
                'preview': previews.get(cls)
            })

        self.fields = sorted(data, key=lambda item: item['name'])
예제 #5
0
파일: migrate.py 프로젝트: timgates42/ptah
def check_version(ev):
    """ ApplicationCreated event handler """
    if not Version.__table__.exists():
        return

    versions = dict((v.package, v.version_num)
                    for v in ptah.get_session().query(Version).all())
    packages = ptah.get_cfg_storage(MIGRATION_ID).keys()

    has_steps = False
    log = logging.getLogger('ptah.alembic')

    for pkg in packages:
        version = versions.get(pkg)
        script = ScriptDirectory(pkg)
        for sc in script.walk_revisions():
            if sc.is_head:
                if sc.revision != version:
                    has_steps = True
                    log.error(
                        "Package '%s' current revision: '%s', head: '%s'", pkg,
                        version, sc.revision)
                break

    if has_steps:
        config.shutdown()
        log.error("Please run `ptah-migrate` script. Stopping...")
        raise SystemExit(1)
예제 #6
0
파일: migrate.py 프로젝트: carlicos/ptah
def check_version(ev):
    """ ApplicationCreated event handler """
    if not Version.__table__.exists():
        return

    versions = dict((v.package, v.version_num)
                    for v in ptah.get_session().query(Version).all())
    packages = ptah.get_cfg_storage(MIGRATION_ID).keys()

    has_steps = False
    log = logging.getLogger('ptah.alembic')

    for pkg in packages:
        version = versions.get(pkg)
        script = ScriptDirectory(pkg)
        for sc in script.walk_revisions():
            if sc.is_head:
                if sc.revision != version:
                    has_steps = True
                    log.error("Package '%s' current revision: '%s', head: '%s'",
                              pkg, version, sc.revision)
                break

    if has_steps:
        config.shutdown()
        log.error("Please run `ptah-migrate` script. Stopping...")
        raise SystemExit(1)
예제 #7
0
파일: settings.py 프로젝트: runyaga/ptah
    def update(self):
        groups = ptah.get_cfg_storage(ID_SETTINGS_GROUP).items()

        data = []
        for name, group in sorted(groups):
            title = group.__title__ or name
            description = group.__description__

            schema = []
            for field in group.__fields__.values():
                schema.append(
                    ({'name': '{0}.{1}'.format(name, field.name),
                      'type': field.__class__.__name__,
                      'value': field.dumps(group[field.name]),
                      'title': field.title,
                      'description': field.description,
                      'default': field.dumps(field.default)}))

            data.append(
                ({'title': title,
                  'description': description,
                  'schema': schema,
                  'name': group.__name__,
                  'ttw': group.__ttw__}))

        return {'data': sorted(data, key=lambda item: item['title'])}
예제 #8
0
    def update(self):
        groups = ptah.get_cfg_storage(ID_SETTINGS_GROUP).items()

        data = []
        for name, group in sorted(groups):
            if self.grps is not None and name not in self.grps:
                continue

            title = group.__title__ or name
            description = group.__description__

            schema = []
            for field in group.__fields__.values():
                if getattr(field, 'tint', False):
                    value = '* * * * * * *'
                else:
                    value = ptah.json.dumps(group[field.name])
                schema.append(
                    ({'name': '{0}.{1}'.format(name, field.name),
                      'type': field.__class__.__name__,
                      'value': value,
                      'title': field.title,
                      'description': field.description,
                      'default': ptah.json.dumps(field.default)}))

            data.append(
                ({'title': title,
                  'description': description,
                  'schema': schema,
                  'name': group.__name__,
                  'ttw': group.__ttw__}))

        return {'data': sorted(data, key=lambda item: item['title'])}
예제 #9
0
    def get_info(self, name):
        group = ptah.get_cfg_storage(ID_SETTINGS_GROUP, self.registry)[name]

        schema = []
        for field in group.__fields__.values():
            if getattr(field, 'tint', False):
                value = '* * * * * * *'
            else:
                value = field.dumps(group[field.name])

            schema.append(({
                'name': '{0}.{1}'.format(name, field.name),
                'type': field.__class__.__name__,
                'value': value,
                'title': field.title,
                'description': field.description,
                'default': field.dumps(field.default)
            }))

        return {
            'title': group.__title__ or name,
            'description': group.__description__,
            'schema': schema,
            'name': group.__name__,
            'ttw': group.__ttw__
        }
예제 #10
0
파일: settings.py 프로젝트: sidloki/ptah
    def update(self):
        groups = ptah.get_cfg_storage(ID_SETTINGS_GROUP).items()

        data = []
        for name, group in sorted(groups):
            if self.grps is not None and name not in self.grps:
                continue

            title = group.__title__ or name
            description = group.__description__

            schema = []
            for field in group.__fields__.values():
                if getattr(field, 'tint', False):
                    value = '* * * * * * *'
                else:
                    value = ptah.json.dumps(group[field.name])
                schema.append(({
                    'name': '{0}.{1}'.format(name, field.name),
                    'type': field.__class__.__name__,
                    'value': value,
                    'title': field.title,
                    'description': field.description,
                    'default': ptah.json.dumps(field.default)
                }))

            data.append(({
                'title': title,
                'description': description,
                'schema': schema,
                'name': group.__name__,
                'ttw': group.__ttw__
            }))

        return {'data': sorted(data, key=lambda item: item['title'])}
예제 #11
0
파일: settings.py 프로젝트: runyaga/ptah
    def update(self):
        groups = ptah.get_cfg_storage(ID_SETTINGS_GROUP).items()

        data = []
        for name, group in sorted(groups):
            title = group.__title__ or name
            description = group.__description__

            schema = []
            for field in group.__fields__.values():
                schema.append(({
                    'name': '{0}.{1}'.format(name, field.name),
                    'type': field.__class__.__name__,
                    'value': field.dumps(group[field.name]),
                    'title': field.title,
                    'description': field.description,
                    'default': field.dumps(field.default)
                }))

            data.append(({
                'title': title,
                'description': description,
                'schema': schema,
                'name': group.__name__,
                'ttw': group.__ttw__
            }))

        return {'data': sorted(data, key=lambda item: item['title'])}
예제 #12
0
    def test_library_simple_js(self):
        ptah.library('test-lib', path='http://ptah.org/test.js', type='js')
        self.init_ptah()
        from ptah.library import LIBRARY_ID
        lib = ptah.get_cfg_storage(LIBRARY_ID)['test-lib']

        self.assertEqual(lib.render(self.request),
                         '<script src="http://ptah.org/test.js"> </script>')
예제 #13
0
    def test_library_render_absurls(self):
        ptah.library('test-lib', path='http://ptah.org/style.css', type='css')
        self.init_ptah()
        from ptah.library import LIBRARY_ID
        lib = ptah.get_cfg_storage(LIBRARY_ID)['test-lib']

        self.assertEqual(
            lib.render(self.request),
            '<link type="text/css" rel="stylesheet" href="http://ptah.org/style.css" />')
예제 #14
0
    def test_library_render_absurls(self):
        ptah.library('test-lib', path='http://ptah.org/style.css', type='css')
        self.init_ptah()
        from ptah.library import LIBRARY_ID
        lib = ptah.get_cfg_storage(LIBRARY_ID)['test-lib']

        self.assertEqual(
            lib.render(self.request),
            '<link type="text/css" rel="stylesheet" href="http://ptah.org/style.css" />'
        )
예제 #15
0
    def test_library_simple_js(self):
        ptah.library(
            'test-lib', path='http://ptah.org/test.js', type='js')
        self.init_ptah()
        from ptah.library import LIBRARY_ID
        lib = ptah.get_cfg_storage(LIBRARY_ID)['test-lib']

        self.assertEqual(
            lib.render(self.request),
            '<script src="http://ptah.org/test.js"> </script>')
예제 #16
0
    def test_library_render_with_extra(self):
        ptah.library(
            'test-lib', path='http://ptah.org/test.js', type='js',
            extra={'test': "extra"})
        self.init_ptah()
        from ptah.library import LIBRARY_ID
        lib = ptah.get_cfg_storage(LIBRARY_ID)['test-lib']

        self.assertEqual(
            lib.render(self.request),
            '<script test="extra" src="http://ptah.org/test.js"> </script>')
예제 #17
0
파일: migrate.py 프로젝트: timgates42/ptah
    def __init__(self, pkg):
        path = ptah.get_cfg_storage(MIGRATION_ID).get(pkg)
        if path is None:
            raise ValueError("Can't find package.")

        res = AssetResolver(pkg)
        self.dir = res.resolve('ptah:scripts').abspath()
        self.versions = res.resolve(path).abspath()

        if not os.access(self.versions, os.F_OK):
            raise alembic.util.CommandError("Path doesn't exist: %r." % path)
예제 #18
0
    def test_register(self):
        from ptah.migrate import MIGRATION_ID

        ptah.register_migration('test', 'ptah.tests:migrations',
                                'Ptah database migration')
        self.init_ptah()

        st = ptah.get_cfg_storage(MIGRATION_ID)

        self.assertIn('test', st)
        self.assertEqual(st['test'], 'ptah.tests:migrations')
예제 #19
0
    def test_register(self):
        from ptah.migrate import MIGRATION_ID

        ptah.register_migration(
            'test', 'ptah.tests:migrations', 'Ptah database migration')
        self.init_ptah()

        st = ptah.get_cfg_storage(MIGRATION_ID)

        self.assertIn('test', st)
        self.assertEqual(st['test'], 'ptah.tests:migrations')
예제 #20
0
파일: migrate.py 프로젝트: carlicos/ptah
    def __init__(self, pkg):
        path = ptah.get_cfg_storage(MIGRATION_ID).get(pkg)
        if path is None:
            raise ValueError("Can't find package.")

        res = AssetResolver(pkg)
        self.dir = res.resolve('ptah:scripts').abspath()
        self.versions = res.resolve(path).abspath()

        if not os.access(self.versions, os.F_OK):
            raise alembic.util.CommandError("Path doesn't exist: %r." % path)
예제 #21
0
    def test_library_render_with_prefix_postfix(self):
        ptah.library(
            'test-lib', path='http://ptah.org/style.css', type='css',
            prefix='<!--[if lt IE 7 ]>', postfix='<![endif]-->')
        self.init_ptah()
        from ptah.library import LIBRARY_ID
        lib = ptah.get_cfg_storage(LIBRARY_ID)['test-lib']

        self.assertEqual(
            lib.render(self.request),
            '<!--[if lt IE 7 ]><link type="text/css" rel="stylesheet" href="http://ptah.org/style.css" /><![endif]-->')
예제 #22
0
    def test_library_render_with_extra(self):
        ptah.library('test-lib',
                     path='http://ptah.org/test.js',
                     type='js',
                     extra={'test': "extra"})
        self.init_ptah()
        from ptah.library import LIBRARY_ID
        lib = ptah.get_cfg_storage(LIBRARY_ID)['test-lib']

        self.assertEqual(
            lib.render(self.request),
            '<script test="extra" src="http://ptah.org/test.js"> </script>')
예제 #23
0
    def test_library_render_with_prefix_postfix(self):
        ptah.library('test-lib',
                     path='http://ptah.org/style.css',
                     type='css',
                     prefix='<!--[if lt IE 7 ]>',
                     postfix='<![endif]-->')
        self.init_ptah()
        from ptah.library import LIBRARY_ID
        lib = ptah.get_cfg_storage(LIBRARY_ID)['test-lib']

        self.assertEqual(
            lib.render(self.request),
            '<!--[if lt IE 7 ]><link type="text/css" rel="stylesheet" href="http://ptah.org/style.css" /><![endif]-->'
        )
예제 #24
0
    def test_library_simple_css(self):
        self.config.add_static_view('tests30', 'ptah.tests:static/dir1')
        ptah.library('test-lib30', path='style.css', type='css')
        self.init_ptah()

        from ptah.library import LIBRARY_ID
        lib = ptah.get_cfg_storage(LIBRARY_ID)['test-lib30']

        self.assertEqual(lib.name, 'test-lib30')
        self.assertEqual(len(lib.entries), 1)
        self.assertEqual(len(lib.entries), 1)
        self.assertTrue('style.css' in lib.entries[0].paths)

        self.assertEqual(repr(lib), '<ptah.Library "test-lib30">')
예제 #25
0
    def update(self):
        context = self.context
        request = self.request
        self.cfg = ptah.get_settings(ptah.CFG_ID_PTAH, request.registry)

        mods = []
        for name, mod in ptah.get_cfg_storage(MANAGE_ID).items():
            if name in self.cfg['disable_modules']:
                continue
            mod = mod(context, request)
            if not mod.available():
                continue
            mods.append((mod.title, mod))

        self.modules = [mod for _t, mod in sorted(mods)]
예제 #26
0
파일: manage.py 프로젝트: runyaga/ptah
    def update(self):
        context = self.context
        request = self.request
        self.cfg = ptah.get_settings(ptah.CFG_ID_PTAH, request.registry)

        mods = []
        for name, mod in ptah.get_cfg_storage(MANAGE_ID).items():
            if name in self.cfg['disable_modules']:
                continue
            mod = mod(context, request)
            if not mod.available():
                continue
            mods.append((mod.title, mod))

        self.modules = [mod for _t, mod in sorted(mods)]
예제 #27
0
    def test_library_simple_css(self):
        self.config.add_static_view('tests30', 'ptah.tests:static/dir1')
        ptah.library('test-lib30',path='style.css',type='css')
        self.init_ptah()

        from ptah.library import LIBRARY_ID
        lib = ptah.get_cfg_storage(LIBRARY_ID)['test-lib30']

        self.assertEqual(lib.name, 'test-lib30')
        self.assertEqual(len(lib.entries), 1)
        self.assertEqual(len(lib.entries), 1)
        self.assertTrue('style.css' in lib.entries[0].paths)

        self.assertEqual(
            repr(lib), '<ptah.Library "test-lib30">')
예제 #28
0
    def test_step_registration(self):
        import ptah

        @ptah.populate('step', title='Step', requires=['test-dep'])
        def step(registry):
            """ """

        self.init_ptah()

        data = ptah.get_cfg_storage(POPULATE_ID)

        self.assertIn('step', data)
        self.assertIs(data['step']['factory'], step)
        self.assertEqual(data['step']['title'], 'Step')
        self.assertTrue(data['step']['active'])
        self.assertEqual(data['step']['requires'], ['test-dep'])
예제 #29
0
    def test_step_registration(self):
        import ptah

        @ptah.populate('step', title='Step', requires=['test-dep'])
        def step(registry):
            """ """

        self.init_ptah()

        data = ptah.get_cfg_storage(POPULATE_ID)

        self.assertIn('step', data)
        self.assertIs(data['step']['factory'], step)
        self.assertEqual(data['step']['title'], 'Step')
        self.assertTrue(data['step']['active'])
        self.assertEqual(data['step']['requires'], ['test-dep'])
예제 #30
0
    def list_modules(self):
        cfg = ptah.get_settings(ptah.CFG_ID_PTAH)
        disabled = cfg['disable_modules']

        mods = []
        for name, mod in ptah.get_cfg_storage(MANAGE_ID).items():
            mods.append(
                 {'id': name,
                  'title': mod.title,
                  'description': mod.__doc__,
                  'disabled': name in disabled})

        for mod in sorted(mods, key=lambda item:item['id']):
            print (grpTitleWrap.fill(
                    '{id}: {title} (disabled: {disabled})'.format(**mod)))
            print (grpDescriptionWrap.fill(mod['description']))
            print ('\n')
예제 #31
0
    def __call__(self, request):
        srv = ptah.get_cfg_storage(ID_REST)[self.srvname]
        url = request.application_url

        info = OrderedDict((('name', srv.name), ('__link__', '%s/' % url),
                            ('title', srv.title),
                            ('description', srv.description), ('actions', [])))

        actions = [(a.title, a.name, a.description)
                   for a in srv.actions.values()]

        for title, name, description in sorted(actions):
            info['actions'].append(
                OrderedDict(
                    (('name', name), ('__link__', '%s/%s' % (url, name)),
                     ('title', title), ('description', description))))

        return info
예제 #32
0
    def get_info(self, name):
        group = ptah.get_cfg_storage(ID_SETTINGS_GROUP, self.registry)[name]

        schema = []
        for field in group.__fields__.values():
            if getattr(field, 'tint', False):
                value = '* * * * * * *'
            else:
                value = field.dumps(group[field.name])

            schema.append(
                ({'name': '{0}.{1}'.format(name, field.name),
                  'type': field.__class__.__name__,
                  'value': value,
                  'title': field.title,
                  'description': field.description,
                  'default': field.dumps(field.default)}))

        return {'title': group.__title__ or name,
                'description': group.__description__,
                'schema': schema,
                'name': group.__name__,
                'ttw': group.__ttw__}
예제 #33
0
    def __call__(self, request):
        srv = ptah.get_cfg_storage(ID_REST)[self.srvname]
        url = request.application_url

        info = OrderedDict(
            (('name', srv.name),
             ('__link__', '%s/' % url),
             ('title', srv.title),
             ('description', srv.description),
             ('actions', [])))

        actions = [(a.title, a.name, a.description)
                   for a in srv.actions.values()]

        for title, name, description in sorted(actions):
            info['actions'].append(
                OrderedDict(
                    (('name', name),
                     ('__link__', '%s/%s' % (url, name)),
                     ('title', title),
                     ('description', description))))

        return info
예제 #34
0
파일: populate.py 프로젝트: carlicos/ptah
    def list_steps(self, p_steps=None, all=False):
        seen = set()

        steps = dict(
            (name, intr) for name, intr in
            ptah.get_cfg_storage(POPULATE_ID, self.registry).items())

        sorted_steps = []
        def _step(name, step):
            if name in seen:
                return

            seen.add(name)

            for dep in step['requires']:
                if dep not in steps:
                    raise RuntimeError(
                        "Can't find populate step '{0}'.".format(dep))
                _step(dep, steps[dep])

            sorted_steps.append(step)

        if p_steps is not None:
            for name in p_steps:
                if name not in steps:
                    raise RuntimeError(
                        "Can't find populate step '{0}'.".format(name))

                _step(name, steps[name])
        else:
            for name, step in steps.items():
                if all:
                    _step(name, step)
                elif step['active']:
                    _step(name, step)

        return sorted_steps
예제 #35
0
    def list_steps(self, p_steps=None, all=False):
        seen = set()

        steps = dict((name, intr) for name, intr in ptah.get_cfg_storage(
            POPULATE_ID, self.registry).items())

        sorted_steps = []

        def _step(name, step):
            if name in seen:
                return

            seen.add(name)

            for dep in step['requires']:
                if dep not in steps:
                    raise RuntimeError(
                        "Can't find populate step '{0}'.".format(dep))
                _step(dep, steps[dep])

            sorted_steps.append(step)

        if p_steps is not None:
            for name in p_steps:
                if name not in steps:
                    raise RuntimeError(
                        "Can't find populate step '{0}'.".format(name))

                _step(name, steps[name])
        else:
            for name, step in steps.items():
                if all:
                    _step(name, step)
                elif step['active']:
                    _step(name, step)

        return sorted_steps
예제 #36
0
def main():
    parser = argparse.ArgumentParser(description="ptah migrate")
    parser.add_argument("config", metavar="config", help="ini config file")

    subparsers = parser.add_subparsers()

    # revision
    subparser = subparsers.add_parser(revision.__name__, help=revision.__doc__)
    subparser.add_argument("package", metavar="package", help="package name")
    subparser.add_argument("-r", "--revision", type=str, dest="revid", help="Unique revision id")
    subparser.add_argument("-m", "--message", type=str, dest="message", help="Message string to use with 'revision'")
    subparser.set_defaults(cmd="revision")

    # current
    subparser = subparsers.add_parser(current.__name__, help=current.__doc__)
    subparser.add_argument("package", metavar="package", nargs="*", help="package name")
    subparser.set_defaults(cmd="current")

    # upgrade
    subparser = subparsers.add_parser(upgrade.__name__, help=upgrade.__doc__)
    subparser.add_argument("package", metavar="package", nargs="*", help="package name")
    subparser.set_defaults(cmd="upgrade")

    # history
    subparser = subparsers.add_parser(history.__name__, help=history.__doc__)
    subparser.add_argument("package", metavar="package", nargs="*", help="package name")
    subparser.set_defaults(cmd="history")

    # list
    subparser = subparsers.add_parser("list", help="List registered migrations.")
    subparser.set_defaults(cmd="list")

    # parse
    args = parser.parse_args()

    # bootstrap pyramid
    env = scripts.bootstrap(args.config)

    if args.cmd == "current":
        print("")
        if not args.package:
            args.package = ptah.get_cfg_storage(MIGRATION_ID).keys()

        for pkg in args.package:
            current(pkg)

    if args.cmd == "revision":
        if args.revid:
            for ch in ",.;-":
                if ch in args.revid:
                    print("Revision id contains forbidden characters")
                    ptah.shutdown()
                    return

        revision(args.package, args.revid, args.message)

    if args.cmd == "upgrade":
        # create db schemas
        create_db_schema(env["registry"], False)

        for pkg in args.package:
            upgrade(pkg)

    if args.cmd == "history":
        if not args.package:
            args.package = ptah.get_cfg_storage(MIGRATION_ID).keys()

        for pkg in args.package:
            history(pkg)

    if args.cmd == "list":
        list_migrations(env["registry"])

    ptah.shutdown()
예제 #37
0
def main():
    parser = argparse.ArgumentParser(description="ptah migrate")
    parser.add_argument('config', metavar='config', help='ini config file')

    subparsers = parser.add_subparsers()

    # revision
    subparser = subparsers.add_parser(revision.__name__, help=revision.__doc__)
    subparser.add_argument('package', metavar='package', help='package name')
    subparser.add_argument("-r",
                           "--revision",
                           type=str,
                           dest='revid',
                           help="Unique revision id")
    subparser.add_argument("-m",
                           "--message",
                           type=str,
                           dest='message',
                           help="Message string to use with 'revision'")
    subparser.set_defaults(cmd='revision')

    # current
    subparser = subparsers.add_parser(current.__name__, help=current.__doc__)
    subparser.add_argument('package',
                           metavar='package',
                           nargs='*',
                           help='package name')
    subparser.set_defaults(cmd='current')

    # upgrade
    subparser = subparsers.add_parser(upgrade.__name__, help=upgrade.__doc__)
    subparser.add_argument('package',
                           metavar='package',
                           nargs='*',
                           help='package name')
    subparser.set_defaults(cmd='upgrade')

    # history
    subparser = subparsers.add_parser(history.__name__, help=history.__doc__)
    subparser.add_argument('package',
                           metavar='package',
                           nargs='*',
                           help='package name')
    subparser.set_defaults(cmd='history')

    # list
    subparser = subparsers.add_parser('list',
                                      help='List registered migrations.')
    subparser.set_defaults(cmd='list')

    # parse
    args = parser.parse_args()

    # bootstrap pyramid
    env = scripts.bootstrap(args.config)

    if args.cmd == 'current':
        print('')
        if not args.package:
            args.package = ptah.get_cfg_storage(MIGRATION_ID).keys()

        for pkg in args.package:
            current(pkg)

    if args.cmd == 'revision':
        if args.revid:
            for ch in ',.;-':
                if ch in args.revid:
                    print('Revision id contains forbidden characters')
                    ptah.shutdown()
                    return

        revision(args.package, args.revid, args.message)

    if args.cmd == 'upgrade':
        # create db schemas
        create_db_schema(env['registry'], False)

        for pkg in args.package:
            upgrade(pkg)

    if args.cmd == 'history':
        if not args.package:
            args.package = ptah.get_cfg_storage(MIGRATION_ID).keys()

        for pkg in args.package:
            history(pkg)

    if args.cmd == 'list':
        list_migrations(env['registry'])

    ptah.shutdown()