[Zope-DB] zsql question

Charlie Clark charlie at egenix.com
Thu Oct 7 16:27:40 EDT 2004

On 2004-10-07 at 20:06:50 [+0200], Jim Abramson <jabramson at wgen.net> wrote:
> That should pretty much do it.
> If you want to go even further, you could write a python script to make
> sure the IP address is valid and make that your if condition:
> <dtml-if "validIpAddress(ipAddress)">insert...
> You could dtml-raise if the ip was _not_ valid (I _think_ that would
> work in a sqlmethod...)


you should always check your data in a PythonScript and only call an ZSQL 
methods when your checks have been met. This makes signalling errors 
easier. However, you should also make sure your database enforces this kind 
of data integrity through constraints:


A reasonable RDBMS will then reject any attempt to insert an "empty" value 
into your table, raise an error and roll-back the transaction. The 
advantage of this is that you do not have to rely on manually checking all 
the various methods of inserting data into your table.

Good luck!

Charlie Clark

Professional Python Services directly from the Source
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::

More information about the Zope-DB mailing list