Hi Arthur.
I do something similar to this.

I chose to implement it in middleware
http://svn.zyons.python-hosting.com/trunk/zilbo/common/text/ 
middleware/Markup.py

in a nutshell, if the 'description' field exists it will create the  
description_html field in the post, which would get applied by the  
standard manipulator

--I
On 24/06/2006, at 2:23 AM, arthur debert wrote:

>
> In a current project, I've got a lot of fields that must accept  
> markup.
> Currently I am using markdown to parse the raw text. I am aware of the
> useful template tags to apply markdown on the template itself, but
> since reads are much more common than writes I would like to store the
> markup on the database, to improve performance. My current solution is
> something like
>
> class Article(Model):
>       raw_text = TextField(maxlength=2000)
>       markup_text = TextField(maxlength=2000, editable=False)
>
>       def save(self):
>               self.markup_text = mardown(self.raw_text)
>               super(Article, self).save()
>
> Which works, but does not feel very  DRYish, since this code is spread
> all over the place .
> I would like to create a MarkupField using it like:
>
> def my_func(text):
>       return markdown.markdown(text)
>
> class Article(Model):
>       body = MarkupField(<regular options for textfield apply>,
> converter=my_func)
>       # where converter would be a fucntion such as markdown or te=xtile or
> rest... or any other
>
>       and the MarkupField would do the conversion before saving to the
> database, on another column in the database to store the markup text.
> Then when accessed from templates I could say {{article.body_markup}}
> and that's it.
>
>       So I guess my question boils down to this:
>       - can a custom field have 2 database columns (one for raw text, and
> another for the markup text)? Is this possible at all?
>       
>       Any pointers will be very much appreciated.
>       
>       Thanks,
>       Arthur
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to