[Maypole] Intelligent CGI/Form processing

Carl Hayter hayter@usc.edu
Thu, 24 Jun 2004 19:19:26 -0700


--ayeiFF771fbkZqVc
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Jun 24, 2004 at 04:53:58PM +0200, Marius Kjeldahl wrote:
> I'm trying to add a customized login template to a Maypole application.=
=20
> Differently from the "bare-bone" data forms generated auto-magically by=
=20
> Maypole and Class::DBI, the login form would typically just prompt for a=
=20
> username and a password. If the username/password pair does not match, I=
=20
> would like to redisplay the same form with an error message (should be ea=
sy=20
> enough), but also with the SAME username as the previous attempt.

my browser does this for me if i wish, plus i can turn it off if i
want.

<snip>
> Template Toolkit has a module named Template::Plugin::CGI which does some=
 of=20
> the job of CGI.pm, but not all of it. By including a [% USE CGI %] at the=
 top=20
> of a template, and then later on in a form [% CGI.input ({Name =3D>=20
> 'username'}) %], the proper input field is displayed, but the field alway=
s=20
> starts out blank.
>=20
> I've also tried using [% CGI.input ({Name =3D> 'email', Default =3D> CGI.=
param=20
> ('email')}) %] (basically setting the default value explicitely), but tha=
t=20
> does not seem to work either.

you might have to force a new query object.
[% q =3D CGI.new; q.input(...) %]

> So how are you other guys doing this effectively within Maypole/Template=
=20
> Toolkit?

i would just do the HTML myself, but if i needed something from CGI
land i would use the query info that Maypole has in in the request
object.

[%# test list template -%]
[%# USE Dumper -%]
[%# Dumper.dump(request) -%]
[% request.query.email %]
[% USE CGI -%]
[% CGI.textarea({ Name =3D> 'email', Default =3D> request.query.email }) %]=
=20

$ export MAYPOLE_TEMPLATES=3D$PWD
$ ./test policy list '?email=3Dbling@example.com'
bling@example.com
<textarea name=3D"email">bling@example.com</textarea>=20


i'm cheating a bit by using query parameters but it should be close
to the same with form parameters.  and i think that should be a
textfield or something else.

----
Carl

--ayeiFF771fbkZqVc
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (SunOS)

iD8DBQFA24utjSUgp1gR7V8RAoF7AJsH7WlABawEsZQQaZQuclCEIm6qIwCgjN7u
fcE+NqS6vtMA4Ps6ONSQiFA=
=bKEy
-----END PGP SIGNATURE-----

--ayeiFF771fbkZqVc--