def __init__(self, dbkey='db'):
     '''Initialize Mongodb backed document storage.
     Arguments:
     dbkey - the key to load database name from default configuration.'''
     client = get_mongoclient()
     db = client[config.get('mongodb', dbkey)]
     self._documents = db['documents']
     self._documents.ensure_index([('name', pm.ASCENDING)], unique=True)
def get_mongoclient():
    return pm.MongoClient(
            config.get('mongodb', 'host'),
            config.getint('mongodb', 'port'))
Exemple #3
0
import cherrypy
import jinja2
import json
import os

from hsm.configuration import config, CONF_FILE_PATH, DICTIONARY_PATH, LDA_PATH
from hsm.data.mongodocumentstorage import MongoDocumentStorage
from hsm.data.mongosegmentstorage import MongoSegmentStorage
from hsm.data.mongosettingsstorage import MongoSettingsStorage
from hsm.server.clustererserver import ClustererServer
from hsm.server.filterserver import FilterServer
from hsm.server.util import mimetype


TEMPLATE_PATH = os.path.join(config.get("/", "tools.staticdir.root"), "templates")
loader = jinja2.FileSystemLoader(TEMPLATE_PATH)
env = jinja2.Environment(loader=loader)


class Server(object):
    def __init__(self, segstorage, docstorage):
        self._segstorage = segstorage
        self._docstorage = docstorage

    @cherrypy.expose
    def index(self):
        raise cherrypy.HTTPRedirect("index.html")

    @cherrypy.expose
    @mimetype("application/hsm")
    def dictionaries(self):