Hello you all. I´m having problem in using FMT atribute of the DTML-VAR tag in dtml methods. The situation is that when I receive some integer data from a MYSQL database, I get it with a L sufix. That makes it necessary to format the data with <dtml-var key fmt="%d">. Now, the problem is that, sometimes, I need to keep on passing the data over to a few dtml methods, and when ever I need to reformat the data, I get an erro message: " Ilegal argument type for built-in operation.". I need to reformat because the data in the other dtml-methods in the sequece may be being received from the MYSQL database. How coud I reformat the data using <dtml-var key FMT="????">, even if it has already been formated by <dtml-var key fmt="%d">? Thanks, Daniel C. Azevedo
Hi Daniel, I have had similar problems with MySQL... What I use to get around it is to send it through the integer module. You'll find this also handy for converting strings that only contain numbers and dates to floats and yadda yadda....: <dtml-var "_.int(varname)"> Anyone got a better one? Or rather, explain why MySQL translates everthing as long integers? Is this ALWAYS the case when defining a dbase field as INT4? Cheers, Paz Daniel Corrêa de Azevedo wrote:
Hello you all. I´m having problem in using FMT atribute of the DTML-VAR tag in dtml methods. The situation is that when I receive some integer data from a MYSQL database, I get it with a L sufix. That makes it necessary to format the data with <dtml-var key fmt="%d">. Now, the problem is that, sometimes, I need to keep on passing the data over to a few dtml methods, and when ever I need to reformat the data, I get an erro message: " Ilegal argument type for built-in operation.". I need to reformat because the data in the other dtml-methods in the sequece may be being received from the MYSQL database. How coud I reformat the data using <dtml-var key FMT="????">, even if it has already been formated by <dtml-var key fmt="%d">?
Thanks, Daniel C. Azevedo
_______________________________________________ Zope maillist - Zope@zope.org 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 )
It sends them back as longs cos the MySQL int is bigger than Python int. ----- Original Message ----- From: "Paul Zwarts" <paul.zwarts@oratrix.com> To: "Daniel Corrêa de Azevedo" <DANIELCA@senado.gov.br> Cc: <zope@zope.org> Sent: Thursday, March 15, 2001 4:12 PM Subject: Re: [Zope] formatting problem...
Hi Daniel,
I have had similar problems with MySQL... What I use to get around it is to send it through the integer module. You'll find this also handy for converting strings that only contain numbers and dates to floats and yadda yadda....:
<dtml-var "_.int(varname)">
Anyone got a better one? Or rather, explain why MySQL translates everthing as long integers? Is this ALWAYS the case when defining a dbase field as INT4? Cheers, Paz
Daniel Corrêa de Azevedo wrote:
Hello you all. I´m having problem in using FMT atribute of the DTML-VAR tag in dtml methods. The situation is that when I receive some integer data from a
MYSQL
database, I get it with a L sufix. That makes it necessary to format the data with <dtml-var key fmt="%d">. Now, the problem is that, sometimes, I need to keep on passing the data over to a few dtml methods, and when ever I need to reformat the data, I get an erro message: " Ilegal argument type for built-in operation.". I need to reformat because the data in the other dtml-methods in the sequece may be being received from the MYSQL database. How coud I reformat the data using <dtml-var key FMT="????">, even if it has already been formated by <dtml-var key fmt="%d">?
Thanks, Daniel C. Azevedo
_______________________________________________ Zope maillist - Zope@zope.org 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 - Zope@zope.org 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 )
Hello, Daniel! Instead of just reformatting the data, you should convert it from a long integer to a plain integer as soon as you get it from the query. Then you'll be able to handle it more easily. This would be a quick fix. A better long term solution would be to investigate why you are gettin long integers from MySQL in the first place, and fix the cause instead of the symptom. If you need any additional help, don't hesitate to contact us. Best regards, Luciano Daniel Corrêa de Azevedo wrote:
Hello you all. I´m having problem in using FMT atribute of the DTML-VAR tag in dtml methods. The situation is that when I receive some integer data from a MYSQL database, I get it with a L sufix. That makes it necessary to format the data with <dtml-var key fmt="%d">. Now, the problem is that, sometimes, I need to keep on passing the data over to a few dtml methods, and when ever I need to reformat the data, I get an erro message: " Ilegal argument type for built-in operation.". I need to reformat because the data in the other dtml-methods in the sequece may be being received from the MYSQL database. How coud I reformat the data using <dtml-var key FMT="????">, even if it has already been formated by <dtml-var key fmt="%d">?
Thanks, Daniel C. Azevedo
_______________________________________________ Zope maillist - Zope@zope.org 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 )
participants (4)
-
Daniel Corrêa de Azevedo -
Luciano Ramalho -
Paul Zwarts -
Phil Harris