[Moin-user] Initialising a search box

Jim Wight j.k.wight at ncl.ac.uk
Mon Feb 14 02:18:10 EST 2005


It could be useful to be able to present a search box already containing
some search terms, e.g. as a hint to the user to confine a search to a
subset of pages. FullSearch doesn't provide an option for that.

It would be easy enough to write a macro based on FullSearch for the
purpose if wikimacro.py weren't so unaccommodating, assuming it is safe
to assign to macro.form['value'] in execute.

The problem is this bit of code in _m_search in wikimacro.py:

    if self.form.has_key('value'):
        default = wikiutil.escape(self.form["value"][0], quote=1)
    else:
        default = ''

because later:

    html = [
        u'<form method="get" action="">',
        u'<div>',
        u'<input type="hidden" name="action" value="fullsearch">',
        u'<input type="hidden" name="titlesearch" value="%i">' % type,
        u'<input name="value" size="30" value="%s">' % default,

In other words, if macro.form['value'] has a value, only the first
character is entered into the box.

I haven't found (yet) where, if anywhere, form["value"] is used, and
hence don't understand why just the first element is extracted.

Jim








More information about the Moin-user mailing list