Beispiel #1
0
def login(username, password, host, port, database):
    global CONNECTION, _USER, _USERNAME, _HOST, _PORT, _DATABASE
    global _VIEW_CACHE, _TOOLBAR_CACHE, _KEYWORD_CACHE
    _VIEW_CACHE = {}
    _TOOLBAR_CACHE = {}
    _KEYWORD_CACHE = {}
    try:
        if CONNECTION is not None:
            CONNECTION.close()
        CONNECTION = ServerPool(host, port, database)
        logging.getLogger(__name__).info('common.db.login(%s, %s)' %
            (username, 'x' * 10))
        with CONNECTION() as conn:
            result = conn.common.db.login(username, password)
        logging.getLogger(__name__).debug(repr(result))
    except socket.error:
        _USER = None
        return -1
    if not result:
        _USER = None
        return -2
    _USER = result[0]
    _USERNAME = username
    session = ':'.join(map(str, [username] + result))
    CONNECTION = ServerPool(host, port, database, session=session)
    _HOST = host
    _PORT = port
    _DATABASE = database
    IPCServer(host, port, database).run()
    return 1
Beispiel #2
0
def login(parameters):
    from tryton import common
    global CONNECTION, _USER
    global _CLIENT_DATE
    host = CONFIG['login.host']
    hostname = common.get_hostname(host)
    port = common.get_port(host)
    database = CONFIG['login.db']
    username = CONFIG['login.login']
    language = CONFIG['client.lang']
    date = CONFIG['login.date']
    connection = ServerProxy(hostname, port, database)
    logging.getLogger(__name__).info('common.db.login(%s, %s, %s)' %
                                     (username, 'x' * 10, language))
    result = connection.common.db.login(username, parameters, language)
    logging.getLogger(__name__).debug(repr(result))
    _USER = result[0]
    session = ':'.join(map(str, [username] + result))
    if CONNECTION is not None:
        CONNECTION.close()
    CONNECTION = ServerPool(hostname,
                            port,
                            database,
                            session=session,
                            cache=not CONFIG['dev'])
    _CLIENT_DATE = date
    bus.listen(CONNECTION)
Beispiel #3
0
def login(parameters):
    from tryton import common
    global CONNECTION, _USER, _USERNAME, _HOST, _PORT, _DATABASE
    global _VIEW_CACHE, _TOOLBAR_CACHE, _KEYWORD_CACHE
    global _CLIENT_DATE
    host = CONFIG['login.host']
    hostname = common.get_hostname(host)
    port = common.get_port(host)
    database = CONFIG['login.db']
    username = CONFIG['login.login']
    language = CONFIG['client.lang']
    date = CONFIG['login.date']
    connection = ServerProxy(hostname, port, database)
    logging.getLogger(__name__).info('common.db.login(%s, %s, %s)' %
                                     (username, 'x' * 10, language))
    result = connection.common.db.login(username, parameters, language)
    logging.getLogger(__name__).debug(repr(result))
    _USER = result[0]
    session = ':'.join(map(str, [username] + result))
    if CONNECTION is not None:
        CONNECTION.close()
    CONNECTION = ServerPool(hostname, port, database, session=session)
    _HOST = host
    _PORT = port
    _DATABASE = database
    _USERNAME = ''
    _CLIENT_DATE = date
    _VIEW_CACHE = {}
    _TOOLBAR_CACHE = {}
    _KEYWORD_CACHE = {}

    bus.listen(CONNECTION)
Beispiel #4
0
def login(host,
          port,
          database,
          username,
          parameters,
          language=None,
          date=None,
          set_date=None):
    global CONNECTION, _USER, _USERNAME, _HOST, _PORT, _DATABASE
    global _VIEW_CACHE, _TOOLBAR_CACHE, _KEYWORD_CACHE
    global _CLIENT_DATE
    connection = ServerProxy(host, port, database)
    logging.getLogger(__name__).info('common.db.login(%s, %s, %s)' %
                                     (username, 'x' * 10, language))
    if set_date:
        _CLIENT_DATE = date
    result = connection.common.db.login(username, parameters, language)
    logging.getLogger(__name__).debug(repr(result))
    _USER = result[0]
    _USERNAME = username
    session = ':'.join(map(str, [username] + result))
    if CONNECTION is not None:
        CONNECTION.close()
    CONNECTION = ServerPool(host, port, database, session=session)
    _HOST = host
    _PORT = port
    _DATABASE = database
    _VIEW_CACHE = {}
    _TOOLBAR_CACHE = {}
    _KEYWORD_CACHE = {}
    IPCServer(host, port, database).run()