On 17 jan, 15:36, Santiago Caracol <santiago.cara...@gmail.com> wrote:
> Sorry the formatting of the code went wrong. Here it is again:
>
> #########################################################
>
> class ContentClassifier(models.Model):
>
>     # <snippet 1>
>     def save(self, *args, **kwargs):
>         self.compile()
>         super(ContentClassifier, self).save(*args, **kwargs)
>     # </snippet 1>
>
>     def compile(self):
>         ...
>         self.posrx = re.compile(regex_string, re.IGNORECASE)
>
>     def classify(self, message):
>         # <snippet2>
>         # self.compile()
>         # </snippet 2>
>
> #########################################################


What does ContentClassifier.__init__ looks like ? Thing is - from what
I can tell from your code at least - that it's the compile() method
that creates the posrx (and negrx) attributes. Since these attributes
are "ordinary" attributes, they aren't saved to the database, so they
aren't loaded from it neither. IOW : you have to call the compile
method (directly or indirectly) before trying to access these
attributes.

FWIW, given the required processing, storing the compiled regexps in
the DB might be a good idea anyway...

-- 
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.

Reply via email to