replace

   {{=body}}

with

   {{=TAG[''](*[P(p) for p in body.split('\n')]) }}

or, if you want to allow HTML tags in texts

   {{=XML(body.replace('\n','<br>'),sanitize=True)}}

of you want to allow WIKI syntax

   {{from gluon.contrib.markdown import WIKI}}
   {{=WIK(body)}}

Massimo

On Jun 25, 9:30 pm, coolaid <[email protected]> wrote:
> I would like to retain the the spacing information (next line, /n)
> when I retrieve text data from the database.
>
> for example, when I put following into a form
>
> test
> test
> test
>
> this is what I get out of the database in the views.
>
> test test test
>
> I'd like it retrieve
>
> test
> test
> test
>
> here is my code
>
> IN CONTROLLERS (default.py, has two functions)
>
> def create_text():
>       form = SQLFORM(db.task, fields=[ 'body'])
>       if form.accepts(request.vars, session):
>               session.flash = 'document saved'
>               redirect(URL(r=request,f='review', args = form.vars.id))
>        elif form.errors: response.flash = 'page not saved'
>        return dict(form=form)
>
> def review():
>       thistask=db((db.task.id==request.args[0])&(db.task.auth_user_id
> ==session.auth.user.id )).select()[0]
>      return dict(body = thistask.body)
>
> IN VIEWS (there are two files)
>
> create_text.html (view to create text)
>
> {{=form}}
>
> review.html (view to edit text)
>
> {{=body}}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to