I am currently using mongo with the Python driver. I want to display
the cursor object using a template engine. But the cursor object turns
out to be not-iterable in the template. I have also tried converting
the cursor object with a dict() method, but it didn't quite give the
the expected result.
My question is, how would one actually iterate or pass the mongo
cursor object to a templating engine? I guess it is not really
helpful, especially for web developers, only to iterate the cursor
object in the python script and not be able to pass it to a template.
Is there any other documentation that I can read besides the Mongo
Python API for this?
Kind regards,
Joshua
objects = []
for object in returned_cursor:
objects.append(object)
I suppose you can, but I just feel that is not really efficient. But
if that is the only way to do it in mongo, then I will go with that.
Kind regards,
Joshua
--
http://twitter.com/projexion
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
The cursor is just an iterable, and it does work in all templating
languages I've tried - if you can send a simple failing test that
would make this much easier to reason about.
As for the example above - the query will only get run when the cursor
is first iterated. If you clone a cursor and then iterate the cloned
cursor and the original cursor separately, two queries will be run -
they don't do any client-side caching or anything like that. Would be
easy to wrap them if that's actually the behavior you want.
--
On Mon, Apr 12, 2010 at 11:19 AM, Лоик <lame...@gmail.com> wrote:
> If you do a rewind() over the cursor it will run an other query?
>
Thank you very much for the insights. It looks like the issue is with
facebook tornado templating engine. I tried with jinja and it works
now.
Kind regards,
Joshua
--
http://twitter.com/projexion
On Apr 12, 11:25 pm, Michael Dirolf <m...@10gen.com> wrote: