On Fri, Feb 11, 2011 at 9:47 AM, Santiago Caracol
<santiago.cara...@gmail.com> wrote:
> Hello,
>
> I have got objects with very large regular expressions:
>
> class Product(models.Model):
>   # ...
>    canonical_name = models.CharField(max_length=200)
>    spelling_variants = models.CharField(max_length=10000, blank=True)
>    lexical_variants = models.CharField(max_length=10000, blank=True)
>    excluded = models.CharField(max_length=10000, blank=True)
>    permutations = models.CharField(max_length=1000, blank=True)
>
> When a product has values for all of the above attributes, it can
> calculate all its possible names. Example: the product 'google android
> 1.1' has several hundred possible names including these:
>
> google android-1.1, oha android-1.1, android-1.1, google android-1,1,
> oha android-1,1, android-1,1, google android-1-1, oha android-1-1,
> android-1-1, google android-11, oha android-11, android-11, google
> android-1 1, oha android-1 1, android-1 1, google android1.1, oha
> android1.1, android1.1, google android1,1, oha android1,1, android1,1,
> google android1-1, oha android1-1, android1-1, google android11, oha
> android11, android11, google android1 1, oha android1 1, android1 1,
> google android 1.1, oha android 1.1, android 1.1, google android 1,1,
> oha android 1,1,
>
> There are products with many more names. Consider the name of the
> mobile phone alcatatel one-touch-800-one-touch-chrome.
>
> Currently every product calculates all its possible names and a
> regular expression that includes the disjunction of all the possible
> names and compiles this regular expression at the time when the
> product is used. This is very inefficient. I would like to compile and
> store the regular expression only once: at the time when the new
> product is saved.
>
> However, there doesn't seem to be a models.RegexField. There is a
> forms.RegexField, but I don't understand how I could use it in the
> product model.
>
> Any tips how to store the compiled regex?
>
> Santiago
>

http://pypi.python.org/pypi/django-picklefield/0.1

Cheers

Tom

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