-class ParamsValidator(UnicodeStringValidator):
- def to_python(self, value, state):
- if isinstance(value, basestring) or value is None:
- value = super(ParamsValidator, self).to_python(value, state)
- try:
- value = params_to_list(value)
- except ParseError, e:
- raise Invalid("invalid parameters in the ParamsCol '%s', parse "
- "error: %s" % (self.name, e), value, state)
- elif not isinstance(value, (list, tuple)):
- raise Invalid("expected a tuple, list or valid string in the "
- "ParamsCol '%s', got %s %r instead"
- % (self.name, type(value), value), value, state)
- return value
- def from_python(self, value, state):
- if isinstance(value, (list, tuple)):
- value = ' '.join([repr(p) for p in value])
- elif isinstance(value, basestring) or value is None:
- value = super(ParamsValidator, self).to_python(value, state)
- try:
- params_to_list(value)
- except ParseError, e:
- raise Invalid("invalid parameters in the ParamsCol '%s', parse "
- "error: %s" % (self.name, e), value, state)
- else:
- raise Invalid("expected a tuple, list or valid string in the "
- "ParamsCol '%s', got %s %r instead"
- % (self.name, type(value), value), value, state)
- return value
-
-class SOParamsCol(SOUnicodeCol):
- def createValidators(self):
- return [ParamsValidator(db_encoding=self.dbEncoding, name=self.name)] \
- + super(SOParamsCol, self).createValidators()
-
-class ParamsCol(UnicodeCol):
- baseClass = SOParamsCol
-
-#}}}
-
-#{{{ Tablas intermedias
-
-# BUG en SQLObject, SQLExpression no tiene cálculo de hash pero se usa como
-# key de un dict. Workarround hasta que lo arreglen.
-SQLExpression.__hash__ = lambda self: hash(str(self))
-
-instancia_tarea_t = table.instancia_tarea
-
-enunciado_tarea_t = table.enunciado_tarea
-
-dependencia_t = table.dependencia
-