示例#1
0
    def load(cls, name, rc_file='~/.oerplibrc'):
        """.. versionadded:: 0.8

        Return a :class:`OERP` session pre-configured and connected
        with informations identified by `name`:

            >>> import oerplib
            >>> oerp = oerplib.OERP.load('foo')

        Such informations are stored with the :func:`OERP.save <oerplib.OERP.save>`
        method.
        """
        data = session.get(name, rc_file)
        if data.get('type') != cls.__name__:
            raise error.Error(
                "'{0}' session is not of type '{1}'".format(
                    name, cls.__name__))
        oerp = cls(
            server=data['server'],
            protocol=data['protocol'],
            port=data['port'],
            timeout=data['timeout'],
        )
        oerp.login(
            user=data['user'], passwd=data['passwd'],
            database=data['database'])
        return oerp
示例#2
0
    def remove(cls, name, rc_file='~/.oerplibrc'):
        """.. versionadded:: 0.8

        Remove the session identified by `name` from the `rc_file` file:

            >>> import oerplib
            >>> oerplib.OERP.remove('foo')
            True
        """
        data = session.get(name, rc_file)
        if data.get('type') != cls.__name__:
            raise error.Error(
                "'{0}' session is not of type '{1}'".format(
                    name, cls.__name__))
        return session.remove(name, rc_file)