Yeah, I started doing that after I posted... Thanks for the advice. I'll be posting this code up on GitHub in a few days, as it's part of a reasonably complete implementation for Django of ISO 19142, Open Geospatial Consortium's Web Feature Service.
-- Jeff On Fri, Jan 20, 2012 at 7:30 AM, francescortiz <francescor...@gmail.com>wrote: > I would pass bound data instead of calling from_request: > > https://docs.djangoproject.com/en/dev/ref/forms/api/#ref-forms-api-bound-unbound > > This way you don't have to worry about forms logic, but just about > filling the default data. > > Francesc > > On Jan 18, 8:42 pm, Jeff Heard <jefferson.r.he...@gmail.com> wrote: > > My basic problem is this: I have multiple kinds of requests that come in, > > and some of them share parameters and valid values and default values. I > > cannot expect my users to pass all form values on the URL line, but > > unpassed parameters must be set to appropriate defaults, not merely None. > > > > These shared parameter sets are broken out into separate RequestForm > > classes, but I also wanted to put the parsing and default values into > those > > classes. So I came up with the "from_request" method, which I put into > each > > RequestForm subclass and created a class method called "create" in > > RequestForm that class every class in cls.mro()'s from_request method > > independently, then calls .clean() on the form to validate it. > > > > Another caveat is that I must shadow the request.GET dictionary with a > > case-insensitive dictionary, which I take care of in the > > django.views.generic.View.dispatch() method. > > > > The code for my proposed solution is here: > > > > http://dpaste.com/hold/689872/ > > > > Does this make sense to people? Sorry to kind of flood the list with > this > > problem all day in different forms, but i think I'm close to having > > something I like. > > > > -- Jeff > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.