thiagovarela.com.br | through flex

CAT | Web development

abr/10

15

PyAMF and Django

Earlier this weak I tried to think of something to put here about a few problems that I was facing with PyAMF, but the words didn’t came out.

But I’m brazilian and I never give up. ;)

Ok, I’m also using Django, and PyAMF DjangoGateway that wraps the django models to Flex value objects.
The fact is that PyAMF doesn’t serialize django foreign key fields unless you explicit specify it on each request, and when they’re null foreign keys you have to pass the related field names as an argument. It sucks, but we can live with it.
The problem is when there are ManyToMany fields and the model related has foreign keys. When PyAMF tries to get the encodable attributes of a many to many relation, it fetches the related data without a select_related() call. And when we do it without selecting the related, we get a KeyError because PyAMF keeps foreign key objects out of serialization.

example:

Model X:
name: CharField …

Model A:
name: …
ex: ForeignKey(Model X)

Model B
name: …
many: ManyToManyField(Model A)

in this cenario, at the current pyamf 0.6 development version, if I try a Model B.objects.all(), it won’t work.

I made some changes in the trunk version to fix those problems for me, but it’s not a good practice.

, ,

Desde 2004 que me atrevo a desenvolver para web. De fato, pouco tempo.

Sempre tive a simplicidade em mente. E na minha busca por isso, conheci diversas linguagens de programação, frameworks e ferramentas.

Javascript, PHP, Python e até Ruby. Não gosto de Java nem de .NET

Frameworks como jQuery e Django tornam a brincadeira bem mais divertida.

Não existe similares em que um seja melhor que o outro, tudo é relativo.

Na minha opinião, o que vale é o que me fizer escrever menos, de forma organizada, clara e objetiva.

Encontrar um que faça isso, é outra história.

(mais…)

No tags

Find it!

Theme Design by devolux.nh2.me

Tag Cloud

django flex pyamf