I'm not following your code very well. I don't understand the
relationship between the first loop and the iter_children() function.

A couple of things that might help:
- Django QuerySets can be qualified with additional tests, so you
could have each of your month/week/etc classes have its own correctly
qualified QuerySet. This will result in one database query for each
event class, and multiple copies of the actual events.
- When you start iterating a QuerySet, it fetches all the model
instances into a list. I think you are trying to use iterators to
prevent this fetch but Django doesnt' work that way. You might as well
just use the list.
- Iterators can't be restarted, I think that is why your latest
iter_children() doesn't work as you expect.

Can you say some more about why you are doing this? Where do all the
initial constraints come from? Do you really have to be so careful to
protect against a 'madman' user? Perhaps you could set a limit on the
number of events you will retrieve and use a count() on the QuerySet
to ensure that not too many records have been fetched. Maybe you
should try a straightforward implementation and when you have
something working you can worry about making it better.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to