[Zope-CMF] Question.... or records attribute.

Ian Ford iford@US.NET
Mon, 8 Oct 2001 15:46:34 -0700


Now if I do modify the script to run a for loop what will happen to the
other vars that are not in the list.
(i.e. total, request_type)

I tried to create the for loop like you stated but I get a syntax error.
Python Code below:

for item in items:
	context.edit(amount=3Ditem.amount)

context.edit(total=3Dtotal
             ,request_type=3Drequest_type
             )
RESPONCE.redirect('%s/view' % context.abslute_url())



-----Original Message-----
From: Jeffrey P Shell [mailto:jeffrey@cuemedia.com]
Sent: Monday, October 08, 2001 3:36 PM
To: Ian Ford
Cc: zope-cmf@zope.org
Subject: Re: [Zope-CMF] Question.... or records attribute.



On Monday, October 8, 2001, at 04:29  PM, Ian Ford wrote:

> I have a form that send a form field call amount to a python script to
> create the catalog entry,
> the form field is being created dynamiclly so a user could enter more
> then one amount.
> (i.e. if a user selects to have two products that they need to order
> then the amount field will display twice.)
>
> I am trying to use the records attribute but it seems to be choking
the
> python script.
> the format that I am send to the python script is
> name=3D'items.amount:records' value=3D'value typed'
>
> On the python script the parameter I am looking for is items.
> Then the context is as follows
>
> context.edit(amount=3Ditems.amount)
>

There is an important distinguishing characteristic between the=20
type 'records' and 'record'.  'records' makes a list of record=20
objects, 'record' makes a single one.

Change your python script to do:

for item in items:
	context.edit(amount=3Ditem.amount)

or change the HTML form to have:
name=3D'item.amount:record' value=3D'value typed'

If your form only has one 'item', you can just use the singular=20
version.  If your form has multiple ones, use the plural, and then=20
use the 'for...' loop in your python script.

Note that even if you only have one record when using the 'records'=20
type, it still gets turned into a sequence.

--
jeffrey@cuemedia.com


_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
requests