Ejemplo n.º 1
0
# This file is part of Multicorn, licensed under a 3-clause BSD license.


from __future__ import print_function
from multicorn.utils import colorize
from multicorn.requests.types import Type, Dict, List
from ... import python_executor
from ..abstract import AbstractCorn
from .wrappers import MongoWrapper

try:
    import pymongo
except ImportError:
    import sys
    print(colorize(
        'yellow',
        "WARNING: The Mongo DB AP is not available."), file=sys.stderr)


class Mongo(AbstractCorn):
    """
    Corn storing items in a Mongo DB noSql server.
    """

    def __init__(self, name, identity_properties,
                 hostname, port, database, collection):
        super(Mongo, self).__init__(name, identity_properties)
        self.hostname = hostname
        self.port = port
        self.database = database
        self.collection_name = collection