[Zope] string formatting

Jonathan (dev101) dev101 at magma.ca
Fri Aug 13 12:28:00 EDT 2010


Something like:

 

<dtml-call "REQUEST.set('signumfix2', signum[0:1] +
_.str(_.int(signum[1:4])+1)">



won’t work because you will turn B006 into B7

 

If you want to retain the leading zeros you will need to pad them. 

 

As Andreas said, this would be better done using a python script (which you
can call from dtml you don’t have to use zpt).

 

 

 

Jonathan

 

From: zope-bounces at zope.org [mailto:zope-bounces at zope.org] On Behalf Of Ebbe
Kvist
Sent: August-13-10 12:17 PM
To: zope at zope.org
Subject: [Zope] string formatting

 

Hi all,

I want to process a variable, signum2, which is picked up from a MySQL
database. The content of the variable is
"B006".
The aim is to process this variable so the result will be 
"B007" and it will then be saved as part of a new record in the database.
The core process is to increment the integer part of the variable "006" with
1.

I have successfully done this incrementation but I have not been able to
create a new 
correct content for the new varable new_xyz.

<dtml-call "REQUEST.set('signumfix2',signum2[1:4])">
<dtml-call "REQUEST.set('signumfix2', _.int(signumfix2)+1)">

How can I from here create the correct content of the new variable? I need
to bring the "B" part
with me and then the incremented integer part formatted with two preceeding
zeroes. Does anyone know?

Best regards,

Ebbe Kvist
Stockholm 

_______________________________________________________________
Hitta kärleken med hjälp av vårt matchningstest - Klicka här!
<http://spray.matchaffinity.se/?mtcmk=614114> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20100813/78ab0c96/attachment.html 


More information about the Zope mailing list