Django连接Odoo XMLRP时的错误

2024-10-04 05:33:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我不能以任何方式与奥多联系,这就是我正在做的:

视图.py

class UserSerializer(ModelSerializer):
    class Meta:
        model = User
        fields = '__all__'

class ProxiedTransport(Transport):

    def set_proxy(self, host, port=None, headers=None):
        self.proxy = host, port
        self.proxy_headers = headers

    def make_connection(self, host):
        connection = http.client.HTTPConnection(*self.proxy)
        connection.set_tunnel(host, headers=self.proxy_headers)
        self._connection = host, connection
        return connection

class ResUser(ViewSet):
    url = 'http://localhost'
    db = 'odoo8'
    username = 'admin'
    password = 'admin'

    def list(self,request,format=None):
        p = ProxiedTransport()
        p.set_proxy('proxy.server',8080)
        common = ServerProxy('{}/xmlrpc/2/common'.format(self.url),p)
        uid = common.authenticate(self.db,self.username,self.password,{})

        return Response({})

但他给了我一个错误:

Request Method:     GET 
Request URL:    http://localhost:8000/odoo-api/res/
Django Version:     2.1 
Exception Type:     gaierror 
Exception Value:    [Errno -2] Name or service not known
Exception Location:     /usr/lib/python3.6/socket.py in getaddrinfo, line 745

问题出在哪里?你知道吗


Tags: pyselfnonehttphostportdefexception