Exemplo n.º 1
0
    def test_two_connections_sharing_data(self):
        connection2 = MongoStore.makeConnection('localhost', MONGODB_TEST_PORT)
        store2 = MongoServerStore(connection2, self.__class__.__name__)
        user = self.mother.make_test_user()

        user2 = store2.read_user(user.ID)
        self.assertEqual(user.ID, user2.ID)
Exemplo n.º 2
0
    def __init__(self):
        self._tmpdir = tempfile.mkdtemp(dir=BII_TEST_FOLDER)
        executable = {
            'darwin': '/opt/local/bin/mongod',
            'win32': 'C:/mongodb/bin/mongod.exe'
        }.get(sys.platform, 'mongod')

        self._process = subprocess.Popen([
            executable, '--bind_ip', 'localhost', '--port',
            str(MONGODB_TEST_PORT), '--dbpath', self._tmpdir, '--nojournal',
            '--nohttpinterface', '--noauth', '--smallfiles', '--syncdelay',
            '0', '--maxConns', '10', '--nssize', '1', '--setParameter',
            'textSearchEnabled=true'
        ],
                                         stderr=subprocess.STDOUT,
                                         stdout=open(os.devnull, 'wb'))
        # Instance without journaling, variable used in mongo_store to not include "j" option
        os.environ["MONGO_DISABLED_JOURNALING"] = "1"
        # XXX: wait for the instance to be ready
        #      Mongo is ready in a glance, we just wait to be able to open a
        #      Connection.
        for _ in range(6):
            time.sleep(0.5)
            try:
                # Using same connection type that real mongo server
                self._conn = MongoStore.makeConnection('localhost',
                                                       MONGODB_TEST_PORT)
            except pymongo.errors.ConnectionFailure:
                continue
            else:
                break
        else:
            self.shutdown()
            assert False, 'Cannot connect to the mongodb test instance'
    def test_two_connections_sharing_data(self):
        connection2 = MongoStore.makeConnection('localhost', MONGODB_TEST_PORT)
        store2 = MongoServerStore(connection2, self.__class__.__name__)
        user = self.mother.make_test_user()

        user2 = store2.read_user(user.ID)
        self.assertEqual(user.ID, user2.ID)
Exemplo n.º 4
0
    def __init__(self):
        self._tmpdir = tempfile.mkdtemp(dir=BII_TEST_FOLDER)
        executable = {'darwin': '/opt/local/bin/mongod',
                      'win32': 'C:/mongodb/bin/mongod.exe'}.get(sys.platform, 'mongod')

        self._process = subprocess.Popen([executable,
                                          '--bind_ip', 'localhost',
                                          '--port', str(MONGODB_TEST_PORT),
                                          '--dbpath', self._tmpdir,
                                          '--nojournal', '--nohttpinterface',
                                          '--noauth', '--smallfiles',
                                          '--syncdelay', '0',
                                          '--maxConns', '10',
                                          '--nssize', '1',
                                          '--setParameter', 'textSearchEnabled=true'
                                          ],
                                         stderr=subprocess.STDOUT,
                                         stdout=open(os.devnull, 'wb')
                                         )
        # Instance without journaling, variable used in mongo_store to not include "j" option
        os.environ["MONGO_DISABLED_JOURNALING"] = "1"
        # XXX: wait for the instance to be ready
        #      Mongo is ready in a glance, we just wait to be able to open a
        #      Connection.
        for _ in range(6):
            time.sleep(0.5)
            try:
                # Using same connection type that real mongo server
                self._conn = MongoStore.makeConnection('localhost', MONGODB_TEST_PORT)
            except pymongo.errors.ConnectionFailure:
                continue
            else:
                break
        else:
            self.shutdown()
            assert False, 'Cannot connect to the mongodb test instance'
Exemplo n.º 5
0
import sys
from biicode.server.rest.rest_api_server import RestApiServer
from biicode.server.conf import BII_MONGO_URI, BII_MEMCACHE_SERVERS,\
    BII_MEMCACHE_USERNAME, BII_MEMCACHE_PASSWORD, BII_MAX_MONGO_POOL_SIZE
from biicode.server.store.mongo_server_store import MongoServerStore
from biicode.server.store.mongo_store import MongoStore

store = MongoServerStore(MongoStore.makeConnection(BII_MONGO_URI,
                                                   max_pool_size=BII_MAX_MONGO_POOL_SIZE))

if BII_MEMCACHE_SERVERS:
    from biicode.server.store.memcache_proxy_store import MemCacheProxyStore
    import pylibmc
    client = pylibmc.Client(servers=[BII_MEMCACHE_SERVERS],
                            username=BII_MEMCACHE_USERNAME,
                            password=BII_MEMCACHE_PASSWORD,
                            binary=True)

    proxy = MemCacheProxyStore(store, client)
else:
    proxy = store

# Run with: gunicorn -b 0.0.0.0:9000 -k gevent_pywsgi biicode.server.rest.production_server:app
ra = RestApiServer(proxy)
app = ra.root_app
Exemplo n.º 6
0
 def __init__(self, connection, databasename=None):
     '''
     connection: MongoClient, can be get from MongoStore.makeConnection
     '''
     MongoStore.__init__(self, connection, databasename)
Exemplo n.º 7
0
# Script for create users in command line

from biicode.server.store.mongo_store import MongoStore
from biicode.server.store.mongo_server_store import MongoServerStore
from biicode.server.conf import BII_MONGO_URI
from biicode.server.user.user_service import UserService
import sys
from biicode.common.model.brl.brl_user import BRLUser
import getpass


connection = MongoStore.makeConnection(BII_MONGO_URI)
database_name = BII_MONGO_URI.split("/").pop()
server_store = MongoServerStore(connection, database_name)


def new_user(login, email, password):   
    service = UserService(server_store, login)
    service.register(login, email, password, True)
    user = server_store.read_user(login)
    user.active = True
    server_store.update_user(user)
    
def change_password(login, password):   
    user = server_store.read_user(login)
    user.password = password
    server_store.update_user(user)
    

def input_new_user():
    print "\n--------new user---------\n"
Exemplo n.º 8
0
 def __init__(self, connection, databasename=None):
     '''
     connection: MongoClient, can be get from MongoStore.makeConnection
     '''
     MongoStore.__init__(self, connection, databasename)
Exemplo n.º 9
0
 def __init__(self, connection, databasename=None):
     MongoStore.__init__(self, connection, databasename)
Exemplo n.º 10
0
 def __init__(self, connection, databasename=None):
     MongoStore.__init__(self, connection, databasename)