Пример #1
0
def main():
    parser = OptionParser(description=__doc__)
    parser.add_option('-C', '--config', dest='config', default=None,
        help="Specify a paster config file. Defaults to $CWD/etc/karl.ini")
    parser.add_option('-d', '--dry-run', dest='dry_run',
        action="store_true", default=False,
        help="Don't commit the transactions")
    parser.add_option('-i', '--interval', dest='commit_interval',
        action="store", default=200,
        help="Commit every N transactions")
    parser.add_option('-p', '--path', dest='path',
        action="store", default=None, metavar='EXPR',
        help="Reindex only objects whose path matches a regular expression")

    options, args = parser.parse_args()
    if args:
        parser.error("Too many parameters: %s" % repr(args))

    commit_interval = int(options.commit_interval)
    if options.path:
        path_re = re.compile(options.path)
    else:
        path_re = None

    config = options.config
    if config is None:
        config = get_default_config()
    root, closer = open_root(config)

    def output(msg):
        print msg

    reindex_catalog(root, path_re=path_re, commit_interval=commit_interval,
                    dry_run=options.dry_run, output=output)
Пример #2
0
def main(args=sys.argv):
    if PGTextIndex is None:
        print >>sys.stderr, NO_PG_TEXT_INDEX
        sys.exit(1)
    parser = OptionParser(description=__doc__)
    parser.add_option('-C', '--config', dest='config', default=None,
        help="Specify a paster config file. Defaults to $CWD/etc/karl.ini")
    parser.add_option('-D', '--dsn', dest='dsn', default=None,
                      help="dsn to connect to postgresql database")
    parser.add_option('-n', '--database-name', dest='database_name',
                      default=None,
                      help="Name of database to connect to")
    parser.add_option('-d', '--dry-run', dest='dry_run',
        action="store_true", default=False,
        help="Don't commit the transactions")
    parser.add_option('-i', '--interval', dest='commit_interval',
        action="store", default=200,
        help="Commit every N transactions")

    options, args = parser.parse_args()
    if args:
        parser.error("Too many parameters: %s" % repr(args))

    commit_interval = int(options.commit_interval)

    config = options.config
    if config is None:
        config = get_default_config()
    root, closer = open_root(config)

    def output(msg):
        print msg

    try:
        index = PGTextIndex(
            get_weighted_textrepr,
            options.dsn, # "dbname=karl user=karl host=localhost password=karl",
            database_name=options.database_name
        )

        if options.dry_run:
            transaction.abort()
        else:
            transaction.commit()

        # reindex_catalog commits its own transactions
        catalog = root.catalog
        catalog['texts'] = index
        reindex_catalog(root, commit_interval=commit_interval,
                         dry_run=options.dry_run, output=output)
    except:
        transaction.abort()
        raise
Пример #3
0
def evolve(context):
    # add 'virtual' index to database and reindex
    def output(msg):
        print msg
    reindex_catalog(context, output=output, indexes=('virtual',))
Пример #4
0
def main(args=sys.argv):
    if PGTextIndex is None:
        print >> sys.stderr, NO_PG_TEXT_INDEX
        sys.exit(1)
    parser = OptionParser(description=__doc__)
    parser.add_option(
        '-C',
        '--config',
        dest='config',
        default=None,
        help="Specify a paster config file. Defaults to $CWD/etc/karl.ini")
    parser.add_option('-D',
                      '--dsn',
                      dest='dsn',
                      default=None,
                      help="dsn to connect to postgresql database")
    parser.add_option('-n',
                      '--database-name',
                      dest='database_name',
                      default=None,
                      help="Name of database to connect to")
    parser.add_option('-d',
                      '--dry-run',
                      dest='dry_run',
                      action="store_true",
                      default=False,
                      help="Don't commit the transactions")
    parser.add_option('-i',
                      '--interval',
                      dest='commit_interval',
                      action="store",
                      default=200,
                      help="Commit every N transactions")

    options, args = parser.parse_args()
    if args:
        parser.error("Too many parameters: %s" % repr(args))

    commit_interval = int(options.commit_interval)

    config = options.config
    if config is None:
        config = get_default_config()
    root, closer = open_root(config)

    def output(msg):
        print msg

    try:
        index = PGTextIndex(
            get_weighted_textrepr,
            options.
            dsn,  # "dbname=karl user=karl host=localhost password=karl",
            database_name=options.database_name)

        if options.dry_run:
            transaction.abort()
        else:
            transaction.commit()

        # reindex_catalog commits its own transactions
        catalog = root.catalog
        catalog['texts'] = index
        reindex_catalog(root,
                        commit_interval=commit_interval,
                        dry_run=options.dry_run,
                        output=output)
    except:
        transaction.abort()
        raise
Пример #5
0
 def _callFUT(self, context, **kw):
     from karl.models.catalog import reindex_catalog
     return reindex_catalog(context, **kw)
Пример #6
0
def evolve(context):
    reindex_catalog(context, indexes=['content_modified'])
Пример #7
0
 def _callFUT(self, context, **kw):
     from karl.models.catalog import reindex_catalog
     return reindex_catalog(context, **kw)
Пример #8
0
def evolve(context):
    # add 'virtual' index to database and reindex
    def output(msg):
        print msg

    reindex_catalog(context, output=output, indexes=('virtual', ))
Пример #9
0
def evolve(context):
    reindex_catalog(context, indexes=['content_modified'])
Пример #10
0
def main():
    parser = OptionParser(description=__doc__)
    parser.add_option(
        '-C',
        '--config',
        dest='config',
        default=None,
        help="Specify a paster config file. Defaults to $CWD/etc/karl.ini")
    parser.add_option('-d',
                      '--dry-run',
                      dest='dry_run',
                      action="store_true",
                      default=False,
                      help="Don't commit the transactions")
    parser.add_option('-i',
                      '--interval',
                      dest='commit_interval',
                      action="store",
                      default=200,
                      help="Commit every N transactions")
    parser.add_option(
        '-p',
        '--path',
        dest='path',
        action="store",
        default=None,
        metavar='EXPR',
        help="Reindex only objects whose path matches a regular expression")
    parser.add_option('-n',
                      '--index',
                      dest='indexes',
                      action="append",
                      help="Reindex only the given index (can be repeated)")

    options, args = parser.parse_args()
    if args:
        parser.error("Too many parameters: %s" % repr(args))

    commit_interval = int(options.commit_interval)
    if options.path:
        path_re = re.compile(options.path)
    else:
        path_re = None

    config = options.config
    if config is None:
        config = get_default_config()
    root, closer = open_root(config)

    def output(msg):
        print msg

    kw = {}
    if options.indexes:
        kw['indexes'] = options.indexes

    reindex_catalog(root,
                    path_re=path_re,
                    commit_interval=commit_interval,
                    dry_run=options.dry_run,
                    output=output,
                    **kw)