@ladonize rtype=list problem

Asked by nelko on 2012-04-23

Hi Jacob,

I have a web service method, which rtype is list.
In this method I use psycopg2 database connection and commad, and it's executing result is a list. I print this result, and it works (the list contains the good result), but when I call this method from a client the return list is empty : {}.
How can I fix it? Or why does it happen?


Question information

English Edit question
ladon Edit question
No assignee Edit question
Last query:
Last reply:

List can be of different types, it can be an integer list or a string list, etc, you cannot return just "list". The best way I've found to return a list object is using a wrapper, like this:

class Page(LadonType):
    content = unicode
    def __init__(self, content):
        self.content = content

class Book(LadonType):
    pages = [Page]
    def __init__(self, pages):
        self.pages = pages


def get_book(rtype=Book):
    return Book([Page(u'Hello'), Page(u'World')])

Kind regards

Can you help with this problem?

Provide an answer of your own, or ask nelko for more information if necessary.

To post a message you must log in.