[Zope] int's as keys for dictionaries

Alec Mitchell apm13 at columbia.edu
Wed May 26 13:04:43 EDT 2004


On Wednesday 26 May 2004 09:53 am, Bryce Harrington wrote:
> On Wed, 26 May 2004, Ben Last (Zope) wrote:
> > > Bryce Harrington
> > >
> > > > > <dtml-let d_test_parameter="{'1':'a', '2':'b'}">
> > >
> > > Yes, that is correct.  The data structure has strings, but I need to
> > > access them using ints as keys.  So I have to convert the ints into
> > > strings in order to retrieve the data.
> >
> > So why not init with
> > d_test_parameter="{1:'a', 2:'b'}
> > ...so that your keys are ints from the beginning?
>
> Zope is converting them to strings on form submission.
>
You may want to use zope's built in request marshalling to deal with this:

<input type="text" name="key:int">

Where the ':int' instructs zope to convert to an integer in the request.

Alec Mitchell



More information about the Zope mailing list