Chris Beaumont wrote:
> 
> Hi,
> 
> I just realized I need to split a potentially pretty long textfield
> input from a web form into 2000 character chunks, for input into a
> database. I see a lot of string functions in DTML, but none that
> looks like it will do this..

Use a Python Script:


<params>yourstring</params>
offset = 0
list=[]

while offset + 2000 < len(yourstring):
        list.append(yourstring[:2000])
        offset = offset + 2000

list.append(yourstring[offset:])

return list

then you can do:

<dtml-in yourexternalmethod>

...with the 2000 char chunks.

Well, hope this helps. I'm sure there's at least one off-by-one bug in
the above. It'd be a lot easier to do if regular expressions were
available in python scripts:

return re.findall('.{0,2000}',yourstring)

...but sadly we're not allowed to use regular expressions in pythno
scripts in case we break something :-((

cheers,

Chris

_______________________________________________
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 )

Reply via email to