开发者

Unexpected HTTP status 500 response

开发者 https://www.devze.com 2022-12-21 10:13 出处:网络
I have a simple python method that should be returned by Django/pyAMF but it\'s returning HTTP Status 500 instead (alt开发者_高级运维hough I do pass through the method with no error and the Grupo obje

I have a simple python method that should be returned by Django/pyAMF but it's returning HTTP Status 500 instead (alt开发者_高级运维hough I do pass through the method with no error and the Grupo object is created):

def newGrupo(request, igID):  
    return { 'grupo': Grupo.objects.create(ig = Ig.objects.get(pk=igID)),
             'membros' : None,
             'reponsavel' : None
        }

The weirdest thing is that another call that do almost the same thing (it actually returns a list of the previous) return ok:

def listGrupos(request, igID):
    result = []
    for grupo in Grupo.objects.filter(ig=igID):
        grp = {}
        grp['grupo'] = grupo
        grp['membros'] = grupo.membro_set.filter(ativo=True)
        grp['responsavel'] = grupo.responsavel
        result.append(grp)

    return result

Any idea why?


Set the logger on the gateway, e.g.:

import logging

from pyamf.remoting.gateway.django import DjangoGateway

services = {}

gw = DjangoGateway(services, logger=logging)

This should help you to get to the root of the problem.


Sounds like a problem with the pyAMF serializer for Django objects.

It works with "model.object.filter" but not with ".create" or ".get".

using "primitives" instead of Django objects avoid the problem:

 return { 'grupo': {"id": g.id},
             'membros' : None,
             'reponsavel' : None
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消