Re: [Rest2web-develop] Added an 'ip_addr' IPv4 address value test...
Brought to you by:
mjfoord
|
From: Michael F. <mi...@pc...> - 2005-07-20 08:39:16
|
Nicola Larosa wrote:
> ...with code tests. Updated the code tests for mixed_list to include IP
> addresses.
>
> This ambiguity of code tests and value tests is tiring me. What if we
> called "checks" the value tests, and just "test" the code tests? I'll
> shoulder the burden of updating docstrings *and* documentation, if you agree.
>
So tests are the doctests and validate performs 'checks' on values.
Ok - *but* are you going to rename the ``Validator.test`` method to
``Validator.check`` ?
I have to recode the Validator support (and therefore the docs) in
ConfigObj anyway - so I'll implement whatever we decide.
I'm liking what you've done with validate.
Thanks for reformatting the docs as well - writing docs on a PDA is
*hard* :-)
Do you think the ``import socket, struct`` belongs in the body of the
module ? This means that importing validate *automatically* imports
socket.. a heavy dependency for just one of the checks.
How about in the body of the module : ::
socket = None
struct = None
In the check :
def dottedQuadToNum(ip):
"""Convert decimal dotted quad string to long integer"""
global socket, struct
if socket is None:
import socket
import struct
and the equivalent in ``numToDottedQuad``.
Another difficulty - if your config file has an IP address with the
relevant check in the configspec then the IP address will be checked and
converted to a long using ``dottedQuadToNum``.
When you come to write out the config file (by calling ``write`` or
``writein`` then the long will be converted using 'str'..... You'd have
to call ``numToDottedQuad`` yourself unless we add an alternative
mechanism (unvalidation ! - registering a str function as well for each
check...)
Did you see your mention in Daily Python URL ?
Regards,
Fuzz
http://www.voidspace.org.uk/python
|