def validate_integer(value, name, min_value=None, max_value=None):
 try:
  value = int(value)
 except (TypeError, ValueError, UnicodeEncodeError):
  raise webob.exc.HTTPBadRequest(explanation=(_('%s must be an integer.') % name))
 if ((min_value is not None) and (value < min_value)):
  raise webob.exc.HTTPBadRequest(explanation=(_('%(value_name)s must be >= %(min_value)d') % {'value_name': name, 'min_value': min_value}))
 if ((max_value is not None) and (value > max_value)):
  raise webob.exc.HTTPBadRequest(explanation=(_('%(value_name)s must be <= %(max_value)d') % {'value_name': name, 'max_value': max_value}))
 return value

def validate_integer ( value , name , min_value = None , max_value = None ) : try : value = int ( value ) except ( TypeError , ValueError , UnicodeEncodeError ) : raise webob . exc . HTTPBadRequest ( explanation = ( _ ( '%s must be an integer.' ) % name ) ) if ( ( min_value is not None ) and ( value < min_value ) ) : raise webob . exc . HTTPBadRequest ( explanation = ( _ ( '%(value_name)s must be >= %(min_value)d' ) % { 'value_name' : name , 'min_value' : min_value } ) ) if ( ( max_value is not None ) and ( value > max_value ) ) : raise webob . exc . HTTPBadRequest ( explanation = ( _ ( '%(value_name)s must be <= %(max_value)d' ) % { 'value_name' : name , 'max_value' : max_value } ) ) return value
make sure that value is a valid integer .