~ack/txaws/xss-hardening

« back to all changes in this revision

Viewing changes to txaws/server/schema.py

  • Committer: Landscape Builder
  • Date: 2012-05-03 20:09:49 UTC
  • mfrom: (14.4.40 staging)
  • Revision ID: landscape-devel@lists.canonical.com-20120503200949-ujcvurr1j30xkr8j
Tags: 12.04.1
Merging from staging for production deployment of 12.04.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
            if not self.allow_none:
94
94
                raise MissingParameterError(self.name)
95
95
            return self.default
96
 
        self._check_range(value)
97
96
        try:
 
97
            self._check_range(value)
98
98
            parsed = self.parse(value)
99
99
            if self.validator and not self.validator(parsed):
100
100
                raise ValueError(value)
179
179
 
180
180
    kind = "integer"
181
181
 
 
182
    lower_than_min_template = "Value must be at least %s."
 
183
    greater_than_max_template = "Value exceeds maximum of %s."
 
184
 
 
185
    def __init__(self, name, optional=False, default=None,
 
186
                 min=0, max=None, allow_none=False, validator=None):
 
187
        super(Integer, self).__init__(name, optional, default, min, max,
 
188
                                      allow_none, validator)
 
189
 
182
190
    def parse(self, value):
183
 
        number = int(value)
184
 
        if number < 0:
185
 
            raise ValueError()
186
 
        return number
 
191
        return int(value)
187
192
 
188
193
    def format(self, value):
189
194
        return str(value)
190
195
 
 
196
    def measure(self, value):
 
197
        return int(value)
 
198
 
191
199
 
192
200
class Bool(Parameter):
193
201
    """A parameter that must be a C{bool}."""