@classmethod<EOL><INDENT>def validateModel(model):<DEDENT>
if model == IndexedRedisModel:<EOL><INDENT>import re<EOL>if re.match('<STR_LIT>', sys.argv[<NUM_LIT:0>]):<EOL><INDENT>return<EOL><DEDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>global validatedModels<EOL>keyName = model.KEY_NAME<EOL>if not keyName:<EOL><INDENT>raise InvalidModelException('<STR_LIT>' %(str(model.__name__), ) )<EOL><DEDENT>if model in validatedModels:<EOL><INDENT>return True<EOL><DEDENT>failedValidationStr = '<STR_LIT>' %(str(model.__name__), ) <EOL>fieldSet = set(model.FIELDS)<EOL>indexedFieldSet = set(model.INDEXED_FIELDS)<EOL>if not fieldSet:<EOL><INDENT>raise InvalidModelException('<STR_LIT>' %(failedValidationStr,))<EOL><DEDENT>if hasattr(model, '<STR_LIT>'):<EOL><INDENT>raise InvalidModelException('<STR_LIT>')<EOL><DEDENT>if hasattr(model, '<STR_LIT>'):<EOL><INDENT>raise InvalidModelException('<STR_LIT>')<EOL><DEDENT>newFields = []<EOL>updatedFields = []<EOL>mustUpdateFields = False<EOL>foreignFields = []<EOL>for thisField in fieldSet:<EOL><INDENT>if thisField == '<STR_LIT>':<EOL><INDENT>raise InvalidModelException('<STR_LIT>' %(failedValidationStr,))<EOL><DEDENT>try:<EOL><INDENT>codecs.ascii_encode(thisField)<EOL><DEDENT>except UnicodeDecodeError as e:<EOL><INDENT>raise InvalidModelException('<STR_LIT>' %(failedValidationStr, to_unicode(thisField), str(e)))<EOL><DEDENT>if issubclass(thisField.__class__, IRForeignLinkFieldBase):<EOL><INDENT>foreignFields.append(thisField)<EOL><DEDENT>if issubclass(thisField.__class__, IRField):<EOL><INDENT>newFields.append(thisField)<EOL><DEDENT>else:<EOL><INDENT>mustUpdateFields = True<EOL>newField = IRClassicField(thisField)<EOL>newFields.append(newField)<EOL>updatedFields.append(thisField)<EOL>thisField = newField<EOL><DEDENT>if str(thisField) == '<STR_LIT>':<EOL><INDENT>raise InvalidModelException('<STR_LIT>' %(failedValidationStr, str(type(thisField)), repr(thisField)   ) )<EOL><DEDENT>if thisField in indexedFieldSet and thisField.CAN_INDEX is False:<EOL><INDENT>raise InvalidModelException('<STR_LIT>' %(failedValidationStr, str(thisField.__class__.__name__), repr(thisField)))<EOL><DEDENT>if hasattr(IndexedRedisModel, thisField) is True:<EOL><INDENT>raise InvalidModelException('<STR_LIT>' %(failedValidationStr, str(thisField)))<EOL><DEDENT><DEDENT>if mustUpdateFields is True:<EOL><INDENT>model.FIELDS = newFields<EOL>deprecatedMessage('<STR_LIT>' %(model.__name__, repr(updatedFields)), '<STR_LIT>' + model.__name__)<EOL><DEDENT>model.FIELDS = KeyList(model.FIELDS)<EOL>if bool(indexedFieldSet - fieldSet):<EOL><INDENT>raise InvalidModelException('<STR_LIT>' %(failedValidationStr, str(list(indexedFieldSet - fieldSet)), ) )<EOL><DEDENT>model.foreignFields = foreignFields<EOL>validatedModels.add(model)<EOL>return True<EOL>
validateModel - Class method that validates a given model is implemented correctly. Will only be validated once, on first model instantiation.

@param model - Implicit of own class

@return - True

@raises - InvalidModelException if there is a problem with the model, and the message contains relevant information.