[...]
>
> 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 looks very impressive. It will take a while for me to fully understand 
the code :-)
But I have a question anyway:
Suppose, you expect an integer "value" that is between 0 and 10.
As I understand your code, one would do something like:
dictCall(checkValue,myDict)

checkValue(value):
        if (value < 0) or (value > 10):
                doErrorProcessing
        else:
                doSomethingUsefull
checkValue.callTypes = {'value':'int'}

Wouldn't it make sense to check for my specific "value" on a lower level, say 
providing the "callTypes" a conversion function:

checkValue.callTypes = {'value':'myint'}

with

def myint(aString):
        anInt = int(aString)
        if (anInt < 0) or (anInt > 10):
                raise "?"
        else:
                return anInt

Or do you think this type of checking should be strictly done by the function 
given to dictCall ?

As a final result I could imagine the following:
 - The page logic (or even the site logic?) is a finite state machine
   (probably living in a session) with the "request" as input. 
 - The "request" is converted according to machinery like the above
 - The appropriate transition is taken
 - The new state takes control (with a possible different "request" machinery)

Anyway, thanks for all the great software you are providing.

Stephan



-------------------------------------------------------
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