Daniel Popowich
dpopowich at comcast.net
Tue Sep 7 10:26:22 EDT 2004
Manera, Villiam writes: > > Date: 03 Sep 2004 11:18:18 -0400 > From: Daniel Popowich <dpopowich at comcast.net> > Subject: Re: [mod_python] servlet form against publisher > To: mod_python user mailing list <mod_python at modpython.org> > Message-ID: <m23c1zbcud.fsf at fenway.local.> > > > Manera, Villiam writes: > > >> ........ > >> Difference in retrieve fields from Form between publisher and servlet: > >> > >> In publischer : req.form = util.FieldStorage(req, keep_blank_values=1) > >> > >> In servlet : self.form = util.FieldStorage(self.req) > >> > >> So in servlet the fields not filled are not inserted in self.form.list > >> > >> Why this choice?? > > >Two reasons: > > >1) Assuming you're going to retrieve the field like this: > > > > field = self.form.getfirst('fieldname', somedefault) > > > > then returning blank values is meaningless: regardless of whether > > or not the field was blank you'll get your default. > > >2) With the mechanics of query_vars and form_vars in mpservlets, re > > automatic retrieval of fields and setting them as instance > > variables and setting defaults for missing fields, there is no > > need to keep blank values. > > >Daniel Popowich > > ===================================== remark ================================== > > Ok, I suppose this reason, and I agree. > But for me will be useful to have a variable in order to choose keep_blank_values=1 when I need it. > > And I need it for most of the routine already written that I'm modifying in order to work fine if they are called from publisher or from servlet. I still don't quite understand why you would need it. Let's say a request comes in like this: http://myserver/myservlet?foo= In the current system, if I set query_vars like this: query_vars = ['foo'] then you get exactly what you need: empty values are stripped by FieldStorage, but Servlet, not seeing the key, will set the instance variable foo to its default, an empty string. Daniel Popowich ----------------------------------------------- http://home.comcast.net/~d.popowich/mpservlets/
|