Theming forms : what am I doing wrong?
In Drupal 7 you need to use drupal_render_children() instead of drupal_render() for the $form. Otherwise, if the form has the #theme property set you will get an infinite loop (as your theme function will invoke the form builder to run your theme function again, and the cycle will continue).