@ladonize rtype=list problem

Asked by nelko

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?

Thanks

Question information

Language:
English Edit question
Status:
Answered
For:
ladon Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Carlos Jenkins Pérez (carlos.jenkins) said :
#1

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.