[Zope-DB] Re: Zope-DB digest, Vol 1 #142 - 1 msg

Kevin Taylor kevin@innovativelinux.com
05 Apr 2002 21:40:29 -0600


*This message was transferred with a trial version of CommuniGate(tm) Pro*
> From: Jeffrey Turmelle <jefft@iri.columbia.edu>
> To: zope-db@zope.org
> Date: 04 Apr 2002 18:27:59 -0500
> Subject: [Zope-DB] How do I trim white space before inserting into database
> 
> This is probably very simple, but I am VERY new to Zope & Python!
> 
> I have a form, which calls a DTML Method for inserting names into a
> database:
> 
> In the following DTML-METHOD
>   checkUniqueName does a select to find out if the name already exists
>   insertName inserts the name into the database.
> 
> I know that this is where I need to use strip() to strip the whitespace
> for the variables (first, last, ...) but how exactly do I do this?
> 
> AddName.dtml:
> 
> <dtml-in checkUniqueName>
>     <p class=byline>The following users currently exist with the name
> <dtml-var last>, <dtml-var first>:<br>
> 
>     <dtml-if sequence-start>
>         <p><table>
>             <tr>
>                 <th>First</th>
>                 <th>Middle</th>
>                 <th>Last</th>
>            </tr>
>    </dtml-if sequence-start>
>     <tr>
>         <td><dtml-var first></td>
>         <td><dtml-var middle></td>
>         <td><dtml-var last></td>
>     </tr>
>     <dtml-if sequence-end>
>         </table>
>     </dtml-if>
> 
> <dtml-else>
>     <dtml-call insertName>
>     <h3><dtml-var first> <dtml-var last> was created</h3>
> 
> </dtml-in>
> 
> 
> Thanks in advance for any guidance,
> 
> Jeff
> 

This isn't a Zope answer, but it would seem to me that you could use
ltrim() in the query to get right of the leading whitespace, or rtrim()
to remove the trailing.  Might give that a try before trying to do it
using python in Zope.

-- 

Kevin Taylor

-----------------------------
Innovative Linux Solutions

kevin@innovativelinux.com

Phone:  (972) 437-0343
Fax:  	(972) 422-8678
Cell:  	(214) 763-9507

280 E. FM 544
Suite 104-113
Murphy, TX 75094-4021
-----------------------------