def intFields(**params):
    """Decorator for cgi fields.  Use like @intFields(foo=None, bar=2)
    where foo is a required parameter, and bar defaults to 2.
    Converts parameters to the given type, leaves other parameters untouched.
    """

    def deco(func):
        def wrapper(self, **kw):
            for name, default in params.iteritems():
                if name in kw:
                    try:
                        value = int(kw[name])
                    except __HOLE__, ve:
                        raise BadParameterError(param=name, badvalue=kw[name])
                elif default is None:
                    raise MissingParameterError(str(name))
                else:
                    value = default
                kw[name] = value
            return func(self, **kw)
        return wrapper
    return deco
dataset/ETHPy150Open sassoftware/conary/conary/web/fields.py/intFields