On Oct 31, 3:00 am, Richard Thomas <chards...@gmail.com> wrote:
> On Oct 31, 5:42 am, Zeynel <azeyn...@gmail.com> wrote:
>
> > class Rep(db.Model):
> >     author = db.UserProperty()
> >     replist = db.ListProperty(str)
> >     unique = db.ListProperty(str)
> >     date = db.DateTimeProperty(auto_now_add=True)
>
> > ....
>
> > Rep().replist = L
> > Rep().put()
> > mylist = Rep().all().fetch(10)
>
> > I am trying to display mylist; but I am getting the object. Thanks.
>
> You're using GAE? I suspect the return value of Query.fetch is an
> iterator and not a list. You can make it a list by passing it to the
> list constructor, like so:
>
> mylist = list(Rep.all().fetch(10))
>
> Richard.

Yes. I am using GAE, thanks. I tried

mylist = list(Rep().all().fetch(10))

and tried to render it with Mako template

% for i in mylist:
${i}
% endfor

I still get the output:

len(mylist): 2
<__main__.Rep object at 0x03AE6C50>
<__main__.Rep object at 0x03AE6270>

As far as I understand there are two items in mylist and they are Rep
objects. But previously I wrote the list L to datastore:

L = []
s = self.request.get('sentence')
L.append(s)

L = L[0].split('\r\n')

Rep().replist = L
Rep().put()
mylist = list(Rep().all().fetch(10))

so I don't understand why I fetch a list and I get an object. Thanks
for your help.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to