2 # Shared type definitions
4 # Mark Huang <mlhuang@cs.princeton.edu>
5 # Copyright (C) 2006 The Trustees of Princeton University
7 # $Id: Parameter.py,v 1.3 2006/10/02 18:32:31 mlhuang Exp $
12 Typed value wrapper. Use in accepts and returns to document method
13 parameters. Set the optional and default attributes for
14 sub-parameters (i.e., dict fields).
17 def __init__(self, type, doc = "",
18 min = None, max = None,
21 # Basic type of the parameter. May be a builtin type or Mixed.
24 # Documentation string for the parameter
27 # Basic value checking. For numeric types, the minimum and
28 # maximum possible values, inclusive. For string types, the
29 # minimum and maximum possible UTF-8 encoded byte lengths.
33 # Whether the sub-parameter is optional or not. If None,
34 # unknown whether it is optional.
35 self.optional = optional
37 # Whether the DB field is read-only.
41 return repr(self.type)
45 A list (technically, a tuple) of types. Use in accepts and returns
46 to document method parameters that may return mixed types.
49 def __new__(cls, *types):
50 return tuple.__new__(cls, types)