Fieldset generators in newforms-admin

3 views
Skip to first unread message

Russell Keith-Magee

unread,
Jul 9, 2007, 10:45:07 AM7/9/07
to Django Developers
Hi all,

I've been taking a look at newforms-admin trying to integrate widget
media definitions (ticket #4418), and encountered a few problems with
the fieldset, fieldset_add, and fieldset_change methods on ModelAdmin.

These three fieldset methods are generators. This means when the
result of fieldset_add is provided to the constructor for AdminForm,
that AdminForm can only iterate over its fieldset once. To date, this
doesn't pose any problems - an AdminForm is a temporary object that is
only needs to be used once - but I need to iterate over the fieldsets
to do some pre-processing.

Is there any particular reason that the fieldset methods are
generators, rather than methods returning lists?

Yours,
Russ Magee %-)

Adrian Holovaty

unread,
Jul 10, 2007, 1:19:02 AM7/10/07
to django-d...@googlegroups.com
On 7/9/07, Russell Keith-Magee <freakb...@gmail.com> wrote:
> I've been taking a look at newforms-admin trying to integrate widget
> media definitions (ticket #4418), and encountered a few problems with
> the fieldset, fieldset_add, and fieldset_change methods on ModelAdmin.
> [...]

> Is there any particular reason that the fieldset methods are
> generators, rather than methods returning lists?

There's no *great* reason behind it. I made those generators for the
standard "use generators" reasons -- more efficient, memory savings,
etc. If there is a compelling reason to change them to return lists,
and a solution with generators isn't possible, feel free to change it.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

Reply all
Reply to author
Forward
0 new messages