[development] The Drupal Diet - Making bootstrap faster
Larry Garfield
larry at garfieldtech.com
Fri May 4 05:15:44 UTC 2007
On Thursday 03 May 2007, Earl Miles wrote:
> Larry Garfield wrote:
> > == Form Handlers ==
> >
> > Forms are nearly always accessed via drupal_get_form() or
> > drupal_execute(). We can therefore do the same sort of centralized
> > improvement for the form system in those functions as we can for page
> > handlers using
>
> I am totally against form getting its own special handling.
>
> 1) logically speaking, pages may or may not be forms; having .page and
> .form is confusing, because in my mind, pages are forms.
Sometimes they are, sometimes they aren't. I'd say the two most often used
forms are the user login block and the search block. Neither of those is a
form.
> 2) pages may also contain forms. Do we then have a .page which also loads a
> .form because the page contains a form?
Such is a possibility.
> 3) Sometimes my page is MOSTLY a form, but I have a little extra code, so I
> don't call drupal_get_form as my callback.
>
> I think splitting forms off are clumsy.
>
> (As someone who has been driving this work, I don't feel compelled to say
> that this is all very important, etc, so don't take this as a big negative;
> just that I think this is, in particular, a poor point to split things at).
The root of the problem is drupal_execute(). drupal_execute() may be called
at any time, in any page handler. We also want to ensure that
drupal_get_form() may be called at any time.
Page handler separation is predicated on the assumption that page handlers are
only ever called from menu_execute_active_handler(). That assumption does
not hold true for forms.
That leaves us 3 options for forms:
1) Forms that are used as a page handler, if factored out to separate files,
may never be called from drupal_execute(). I do not consider this
acceptable.
2) Forms may not be factored out into separate files at all. Everything still
works, but then there's a lot of form code hanging around we never use.
3) Forms get a separate loading mechanism from pages. This way
drupal_get_form() and drupal_execute() still function everywhere and we can
still factor out forms to separate files where appropriate.
I want to emphasize that "where appropriate". Not all handlers or forms
should be split out into separate files. For instance, I'd argue the most
often used page handler is node_view(), and the most often used forms are the
login block and search block. We should *not* split those out into separate
files. They're used often enough that their extra weight on other page loads
is a good trade off for avoiding the disk hit. Similar decisions can/should
be made on a module-by-module basis. So no, we're not ballooning the disk IO
this way.
--
Larry Garfield AIM: LOLG42
larry at garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
More information about the development
mailing list