1

Djangoでsoapサービスを起動するタスクがあります(コマースソフトウェアからデータを受信するため)

soaplib2.0.0beta をインストールし、soap から django へのレイヤーを作成しました (Django スニペットを使用) いくつかの soap メソッドとデータ型を作成しました。すべてが suds (lib) テストで動作しますが、本番環境ではエラーが発生します。

エラーは、一部の列が一意ではないことを示していますが、データは問題なく、メソッドは db に接続できます (.all().count() テスト)。

レイヤーかnginxの設定が間違っていると思います...

層のコード:

# Code of Layer:
class DjangoSoapApp(Application):
    def __call__(self, request):
        # wrap the soaplib response into a Django response object
        django_response = HttpResponse()
        def start_response(status, headers):
            status, reason = status.split(' ', 1)
            django_response.status_code = int(status)
            for header, value in headers:
                django_response[header] = value
        response = super(DjangoSoapApp, self).__call__(request.META, start_response)
        django_response.content = '\n'.join(response)
        return django_response

メソッドのコード:

# Method's code
class SyncService(DefinitionBase):

    @rpc(User, Order, _returns=Array(Response))
    def CreateOrder(self, user=None, order=None):
        response = []

        # response.append(Response(Result = True, Response = "ORDERS: " + str(self.tmp.count())))
        # return response

        if not user or not order:
            response.append(Response(Result = False, Response = "Exception: not send user or order"))
            return response
        try:
            new_user = user_model.objects.get(commerce_uid=user.Id)
            response.append(Response(Result = True, Response="Success: Get user %s %s" % (user.Name, user.EMail)))
        except Exception as e:
            try:
                new_user = user_model(
                    email=user.EMail,
                    commerce_uid=user.Id,
                    telephone=user.Phone,
                    name=user.Name,
                    username=re.sub(r'\.|\@', '', user.EMail),
                    isSync = True)
                new_user.save()
                response.append(Response(Result = True,Response = "Success: Create user %s %s" % (user.Name, user.EMail)))
            except Exception as e:
                response.append(Response(Result = False, Response = "Exception: user '%s' not found and can't create (%s)" % (user, e)))
                return response

        try:
            new_order = order_model(
                user=new_user,
                date=order.Date,
                time=order.Time,
                boat=order.Boat,
                amount=order.Quantity,
                isSync=True
            )
            new_order.save()
            response.append(Response(Result = True, Response = "Success: Create order %s" % (order)))
        except Exception as e:
            response.append(Response(Result = False, Response = "Exception: Can't create order '%s' for user '%s' (%s)" % (order, user, e)))
            return response

        return response

エラーの例:

Exception: user 'Id: 6d73d109-4b7b-453e-819a-94c42a883c09, Name: John Smith 2, Email: email2@email.com, Phone: +749512345679' not found and can't create (column commerce_uid is not unique)
4

0 に答える 0