Example #1
0
 def __setattr__(self, item, value):
     if item == 'content':
         assert isinstance(value, list)
         for val in value:
             assert isinstance(val, Content)
         self.__dict__['_content'] = Converter.encode(value)
     elif item == 'param_changes':
         assert isinstance(value, list)
         for val in value:
             assert isinstance(val, ParamChange)
         self.__dict__['_param_changes'] = Converter.encode(value)
     elif item == 'widget':
         assert isinstance(value, list)
         for val in value:
             assert isinstance(val, WidgetInstance)
         self.__dict__['_widget'] = Converter.encode(value)
     elif item == 'unresolved_answers':
         assert isinstance(value, dict)
         for key, val in value.iteritems():
             assert isinstance(key, basestring)
             assert isinstance(val, int)
         self.__dict__['unresolved_answers'] = value
     elif item in django_internal_attrs or item in [
         'name', '_content', '_param_changes', '_widget', '_json_field_cache'
     ]:
         self.__dict__[item] = value
     else:
         raise AttributeError(item)
Example #2
0
 def __setattr__(self, item, value):
     """We encode a list of Rule objects into a JSON object using
     Converter.encode"""
     if item == 'rules':
         assert isinstance(value, list)
         for val in value:
             assert isinstance(val, Rule)
         self.__dict__['_rules'] = Converter.encode(value)
     elif item in django_internal_attrs or item in [
         '_rules', 'name', 'classifier', '_json_field_cache'
     ]:
         self.__dict__[item] = value
     else:
         raise AttributeError(item)
Example #3
0
 def __setattr__(self, item, value):
     """We encode a list of AnswerHandler objects into a JSON object using
     Converter.encode"""
     if item == 'handlers':
         assert isinstance(value, list)
         for val in value:
             assert isinstance(val, AnswerHandlerInstance)
         self.__dict__['_handlers'] = Converter.encode(value)
     elif item == 'params':
         assert isinstance(value, dict)
         for val in value:
             assert isinstance(val, basestring)
         self.__dict__['params'] = value
     elif item in django_internal_attrs or item in [
         '_handlers', 'widget_id', 'params', 'sticky', '_json_field_cache'
     ]:
         self.__dict__[item] = value
     else:
         raise AttributeError(item)
Example #4
0
 def __setattr__(self, item, value):
     """Encode a list of ParamChange objects to JSON object."""
     if item == 'param_changes':
         assert isinstance(value, list)
         for val in value:
             assert isinstance(val, ParamChange)
         self.__dict__['_param_changes'] = Converter.encode(value)
     elif item == 'feedback':
         assert isinstance(value, list)
         for val in value:
             assert isinstance(val, basestring)
         self.__dict__['feedback'] = value
     elif item in django_internal_attrs or item in [
         '_param_changes',
         'name',
         'inputs',
         'dest',
         'feedback',
         '_json_field_cache'
     ]:
         self.__dict__[item] = value
     else:
         raise AttributeError(item)