On Thu, 2003-03-06 at 04:24, Stephan Diehl wrote:
> > I've also thought about it for requests, though it becomes awkward as
> > well when you don't want to depend on all the variables being present.
> > Now the idea top in my mind is expansion, like:
> >
> >     def someAction(self, var1, var2_int, var3="something"):
> >         ...
> >
> > So that var1 and var2 would be required variables, and var2 would be
> > turned into an int.  I hate Zope's method of using an HTML variable name
> > of var2:int, and I'd rather see the HTML have var2, and the function
> > definition have the type declaration in it.
> 
> This sounds neat. I'd even like to have some machinery in place to check the 
> content of the request variables not only on type but for value (like you are 
> doing in your FunFormKit)

I'd been thinking about this for a while -- something for form
processing that's lighter then FFK, when you don't really need the error
cycle that FFK has.  Anyway, I finally coded it up, it's in CVS in
WebKit/Experimental/DictCall.py.

This was the example of its use that seemed most compelling to me:

Make a form like this:

for i in range(len(names)):
    self.write('<input type="text" name="names:%i:fname" value="%s">'
               % (i, htmlEncode(names[i]['fname'])))
    self.write('<input type="text" name="names:%i:lname" value="%s">'
               % (i, htmlEncode(names[i]['fname'])))

When it's submitted, say it goes to a form using DictCall:

dictCall(self.saveNames, self.request().fields())

def saveNames(self, names):
    # ...
saveNames.callTypes = {'names': 'list,dict'}

DictCall will unpack those field names and essentially reconstruct the
names variable (except with edits).

For registration forms and such, FFK has some useful features.  But for,
say, a tabular list where you have checkboxes to do a delete, I think
this will work better.

  Ian




-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to