You could use FSCounter to do your counting:
http://www.zope.org/Members/andym/wiki/FSCounter.
There is a How-To on using unique_ids:
http://www.zope.org/Members/andym/FSCounter/unique_ids
In your code try explicilty using an int:
dtml-call "REQUEST.set('my_number', _.int(my_number) + 1)"
--
Andy McKay, Developer.
ActiveState.
- Original Message -
From: "César A. K. Grossmann" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, December 11, 2000 10:44 AM
Subject: [Zope] Incrementing a form field
Hi!
I have a form that is used to insert some records to a database, and one
of the fields is a sequence number. I want to increment this number when
the form is used, unless is the first time it is loaded.
The form (idea copied from the SmartForms HOWTO) have the name
"Register", and is something like this:
dtml-var standard_html_header
dtml-if "REQUEST.REQUEST_METHOD=='POST'"
Record inserted.
/dtml-if
dtml-if my_number
dtml-call "REQUEST.set('my_number', my_number + 1)"
dtml-else
dtml-call "REQUEST.set('my_number', 1)"
/dtml-if
form action="Register" method="POST"
A Field input name="my_field" value="some value"br
A Number input name="my_number" value="dtml-var my_number"br
input type="submit" value="OK"
/form
dtml-var standard_html_footer
It work for the first load, but when I press the OK button, I get an
error message:
Error Type: TypeError
Error Value: illegal argument type for built-in operation
The traceback:
!--
Traceback (innermost last):
File /usr/lib/python1.5/site-packages/ZPublisher/Publish.py, line 222,
in publish_module
File /usr/lib/python1.5/site-packages/ZPublisher/Publish.py, line 187,
in publish
File /usr/share/zope/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
(Object: Traversable)
File /usr/lib/python1.5/site-packages/ZPublisher/Publish.py, line 171,
in publish
File /usr/lib/python1.5/site-packages/ZPublisher/mapply.py, line 160,
in mapply
(Object: Register)
File /usr/lib/python1.5/site-packages/ZPublisher/Publish.py, line 112,
in call_object
(Object: Register)
File /usr/share/zope/lib/python/OFS/DTMLMethod.py, line 172, in
__call__
(Object: Register)
File /usr/lib/python1.5/site-packages/DocumentTemplate/DT_String.py,
line 528, in __call__
(Object: Register)
File /usr/lib/python1.5/site-packages/DocumentTemplate/DT_Util.py,
line 342, in eval
(Object: REQUEST.set('my_number', my_number + 1))
(Info: REQUEST)
File string, line 0, in ?
TypeError: (see above)
--
What is wrong? How do I increment the value?
[]s
--
+-+-+
| César A. K. Grossmann | Capacitação Solidária |
| [EMAIL PROTECTED]| http://www.uol.com.br/umminuto/ |
| http://members.xoom.com/ckant/ | Clique e doe - é de graça |
+-+-+
http://www.halcyon.com/sciclub/cgi-pvt/instr/instr.html
A ética do iG: http://antispambr.abranetrj.org.br/not-20001023.html
One Bell System - it used to work before they installed the Dimension!
___
Zope maillist - [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope-dev )
___
Zope maillist - [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope-dev )