Hello, I have got a model called ContentClassifier which uses regular expressions to classify the content of messages. It has a method compile() that compiles an instance's regular expressions into self.posrx. When the classify method calls compile, i.e. when each ContentClassifier compiles its regular expressions every time it's classify-method is called, then the ContentClassifiers work as expected. (I.e. if, in the code given below snippet 2 instead of snippet 1 is used). If, on the other hand, I want each instance to compile its regular expressions when it is saved (i.e. if I use snippet 1 instead of snippet 2), Django says
AttributeError: ... ContentClassifier' object has no attribute 'posrx' Why? ######################################################### class ContentClassifier(models.Model): def save(self, *args, **kwargs): # snippet 1 self.compile() # snippet 1 super(ContentClassifier, self).save(*args, **kwargs) # snippet 1 def compile(self): ... self.posrx = re.compile(regex_string, re.IGNORECASE) def classify(self, message): # self.compile() # snippet 2 ######################################################### -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.