Пример #1
0
def main():
    parser = OptionParser(description=__doc__)
    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)")
    parser.add_option('-s', '--site', dest='site',
        action="store", default=None, metavar='PATH')

    options, args = parser.parse_args()

    if args:
        config_uri = args[0]
    else:
        parser.error("Requires a config_uri as an argument")

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

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

    setup_logging(config_uri)
    env = bootstrap(config_uri)
    site = env['root']
    if options.site:
        site = traverse(site, options.site)

    catalog = find_service(site, 'catalog')

    if catalog is None:
        raise KeyError('No catalog service found at ' % resource_path(site))

    catalog.reindex(path_re=path_re, commit_interval=commit_interval,
                    dry_run=options.dry_run, **kw)
Пример #2
0
    def document_view(self):
        self.title = self.context.title

        objectid = -1099536351
        from substanced.service import find_service
        objectmap = find_service(self.context, 'objectmap')
        rel = 'document-to-topic'
        topic = objectmap.object_for(objectid)
        print list(objectmap.sources(topic, rel))
        print list(objectmap.targets(self.context, rel))
        #objectmap.connect(self.context, topic, 'document-to-topic')





        return dict(body=self.context.body, topic=topic)
Пример #3
0
 def disconnect(self):
     topics = self.get_topicids()
     objectmap = find_service(self, 'objectmap')
     for topicid in topics:
         objectmap.disconnect(self, topicid, DocumentToTopic)
Пример #4
0
 def connect(self, *topics):
     objectmap = find_service(self, 'objectmap')
     for topicid in topics:
         objectmap.connect(self, topicid, DocumentToTopic)
Пример #5
0
 def get_topicids(self):
     objectmap = find_service(self, 'objectmap')
     return objectmap.targetids(self, DocumentToTopic)
Пример #6
0
 def disconnect(self):
     topics = self.get_topicids()
     objectmap = find_service(self, 'objectmap')
     for topicid in topics:
         objectmap.disconnect(self, topicid, DocumentToTopic)
Пример #7
0
 def connect(self, *topics):
     objectmap = find_service(self, 'objectmap')
     for topicid in topics:
         objectmap.connect(self, topicid, DocumentToTopic)
Пример #8
0
 def get_topicids(self):
     objectmap = find_service(self, 'objectmap')
     return objectmap.targetids(self, DocumentToTopic)