PEATDB/Base.py
def createStorage(self, server, username, password,
                      project, port, backend):
        """Create the specified storage from given options"""

        if backend == 'mysql':
            #we now use RelStorage by default, mysql backend
            from relstorage.adapters.mysql import MySQLAdapter
            from relstorage.storage import RelStorage
            from MySQLdb import OperationalError
            try:
                self.adapter = MySQLAdapter(host=server, user=username,
                                            passwd=password, db=project, port=port,
                                            connect_timeout=3)
                self.storage = RelStorage(self.adapter)
                                          #shared_blob_dir=False, blob_dir=self.blob_dir)
            except OperationalError, message:
                self.connection = None; self.dbroot = None
                self.errormessage = message
                return False
        else:
            #otherwise we try to use clientstorage/ZEO
            from ZEO.ClientStorage import ClientStorage
            server_and_port = (server, port)
            self.storage = ClientStorage(server_and_port,
                                             storage=project,
                                             username=username,
                                             password=password,
                                             wait=False,
                                             wait_timeout=50,
                                             blob_dir=self.blob_dir)
            #can't raise exception here if connection fails..
            if 'disconnected' in self.storage.getName():
                self.connection = None; self.dbroot = None
                self.errormessage = 'Zeo error'
                return False
        return True
Create the specified storage from given options
Create the specified storage from given options
Create the specified storage from given options
def createStorage(self, server, username, password,
                      project, port, backend):
        if backend == 'mysql':
            from relstorage.adapters.mysql import MySQLAdapter
            from relstorage.storage import RelStorage
            from MySQLdb import OperationalError
            try:
                self.adapter = MySQLAdapter(host=server, user=username,
                                            passwd=password, db=project, port=port,
                                            connect_timeout=3)
                self.storage = RelStorage(self.adapter)
            except OperationalError, message:
                self.connection = None; self.dbroot = None
                self.errormessage = message
                return False
        else:
            from ZEO.ClientStorage import ClientStorage
            server_and_port = (server, port)
            self.storage = ClientStorage(server_and_port,
                                             storage=project,
                                             username=username,
                                             password=password,
                                             wait=False,
                                             wait_timeout=50,
                                             blob_dir=self.blob_dir)
            if 'disconnected' in self.storage.getName():
                self.connection = None; self.dbroot = None
                self.errormessage = 'Zeo error'
                return False
        return True
def createStorage ( self , server , username , password , project , port , backend ) : if backend == 'mysql' : from relstorage . adapters . mysql import MySQLAdapter from relstorage . storage import RelStorage from MySQLdb import OperationalError try : self . adapter = MySQLAdapter ( host = server , user = username , passwd = password , db = project , port = port , connect_timeout = 3 ) self . storage = RelStorage ( self . adapter ) except OperationalError , message : self . connection = None ; self . dbroot = None self . errormessage = message return False else : from ZEO . ClientStorage import ClientStorage server_and_port = ( server , port ) self . storage = ClientStorage ( server_and_port , storage = project , username = username , password = password , wait = False , wait_timeout = 50 , blob_dir = self . blob_dir ) if 'disconnected' in self . storage . getName ( ) : self . connection = None ; self . dbroot = None self . errormessage = 'Zeo error' return False return True
Create the specified storage from given options
Create the specified storage from given options
"""Create the specified storage from given options""" #we now use RelStorage by default, mysql backend #shared_blob_dir=False, blob_dir=self.blob_dir) #otherwise we try to use clientstorage/ZEO #can't raise exception here if connection fails..
self
server
username
password
project
port
backend