IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Re: Django newforms...

Beginnings of the new documentation are [link|http://www.djangoproject.com/documentation/newforms/|here].

\r\n\r\n

In a nutshell:

\r\n\r\n
    \r\n
  • Manipulators were cumbersome to write, so a declarative metaclass has been introduced for specifying form fields. Form classes can now be declared in much the same way as models.
  • \r\n
  • Separation of several concerns; there's now a "widget" layer which handles the actual HTML presentation, and allows you to interchangeably specify different widget types for different fields in the form class.
  • \r\n
  • Easier usage; instead of the nasty copy-POSTdata-into-dict-and-validate stuff, you can now pass request.POST directly to a form, and forms have an is_valid method carries out validation for you on demand; you can then read known-good data out of the form's clean_data dictionary, which will also have the values converted to appropriate Python types (removing the need for do_html2python).
  • \r\n
  • Custom validation methods can be declared as methods of the form class, taking their names from fields they validate; a clean_foo method will be called to validate the form field named foo, for example.
  • \r\n
  • The internals of newforms work purely with Unicode strings, and we're moving toward having all of Django's internals do that to get out of the hell of "what encoding is this data in".
  • \r\n
\r\n\r\n

So far I'm a big fan of it; I was able to whip up [link|http://django-registration.googlecode.com/svn/trunk/forms.py|a nice little user-registration form] without much code at all, as my first foray into newforms.

\r\n\r\n

The integration into the admin is going to be the next big step; the admin app is getting heavily refactored to take full advantage of newforms and add a lot more flexibility (for example, you'll be able to easily override individual parts of the admin, with full access to the request to do more advanced permissions filtering).

--\r\nYou cooin' with my bird?
Collapse Edited by ubernostrum May 5, 2007, 09:21:19 PM EDT
Re: Django newforms...

Beginnings of the new documentation are [link|http://www.djangoproject.com/documentation/newforms/|here].

In a nutshell:

  • Manipulators were cumbersome to write, so a declarative metaclass has been introduced for specifying form fields. Form classes can now be declared in much the same way as models.
  • Separation of several concerns; there's now a "widget" layer which handles the actual HTML presentation, and allows you to interchangeably specify different widget types for different fields in the form class.
  • Easier usage; instead of the nasty copy-POSTdata-into-dict-and-validate stuff, you can now pass request.POST directly to a form, and forms have an is_valid method carries out validation for you on demand; you can then read known-good data out of the form's clean_data dictionary, which will also have the values converted to appropriate Python types (removing the need for do_html2python).
  • Custom validation methods can be declared as methods of the form class, taking their names from fields they validate; a clean_foo method will be called to validate the form field named foo, for example.
  • The internals of newforms work purely with Unicode strings, and we're moving toward having all of Django's internals do that to get out of the hell of "what encoding is this data in".

So far I'm a big fan of it; I was able to whip up [link|http://django-registration.googlecode.com/svn/trunk/forms.py|a nice little user-registration form without much code at all, as my first foray into newforms.

The integration into the admin is going to be the next big step; the admin app is getting heavily refactored to take full advantage of newforms and add a lot more flexibility (for example, you'll be able to easily override individual parts of the admin, with full access to the request to do more advanced permissions filtering).

-- You cooin' with my bird?
New Good deal.
Doesn't sound like porting to newforms will be a huge concern, either. The concepts are mostly the same; just move the logic somewhere else.

I remember when Twisted went from woven to nevow. What a cluster that was.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Yeah.

The admin migration will involve some code changes because we're taking the opportunity to move admin definitions out of the model classes, but aside from that it's not a terribly difficult change to make, and code ends up a lot cleaner afterwards.

--\r\nYou cooin' with my bird?
New I don't use the admin stuff
So no big deal.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
     Nifty demo of J2EE vs Zope vs RoR vs django vs etc ... - (drewk) - (32)
         WooHoo! J2EE is the way to go! ;-) -NT - (Another Scott)
         Thoughts... - (admin) - (27)
             Other thoughts - (tuberculosis) - (16)
                 Other other thoughts... - (admin) - (14)
                     Builder pattern - (tuberculosis) - (13)
                         Not impressed. - (admin) - (5)
                             You still don't get it - (tuberculosis) - (4)
                                 No, I get it just fine. - (admin) - (3)
                                     Been there before - maintenance Hell - not going back -NT - (tuberculosis) - (2)
                                         Your experience differs from mine. -NT - (admin) - (1)
                                             Apparently so -NT - (tuberculosis)
                         Builder pattern... :-O - (static) - (1)
                             Two things - (tuberculosis)
                         Oi! Even if your screen is six foot wide, not everyone's is! - (CRConrad) - (4)
                             Do you have a 1886 Volvo CRT, too? - (Another Scott) - (1)
                                 El Cheapo older(ish) HP laptop, 1024 x 768 I think. - (CRConrad)
                             Yah sure - done -NT - (tuberculosis) - (1)
                                 Great, Thanks. -NT - (CRConrad)
                 Document generation in code - (ubernostrum)
             Thanks. - (Another Scott) - (9)
                 If you only saw half you missed the best parts. :-) - (admin) - (8)
                     What was at the end? - (drewk) - (1)
                         He built an actual application with each. - (admin)
                     Re: If you only saw half you missed the best parts. :-) - (ubernostrum) - (5)
                         Django newforms... - (admin) - (4)
                             Re: Django newforms... - (ubernostrum) - (3)
                                 Good deal. - (admin) - (2)
                                     Yeah. - (ubernostrum) - (1)
                                         I don't use the admin stuff - (admin)
         He needed to investigate integration - (warmachine) - (2)
             Depends on what you're doing - (admin) - (1)
                 I have back-ends - (warmachine)

But if you call right now, you might get an appointment by then.
150 ms