Hello,

I need to truncate a field that contains HTML content. 

Now i'm using htmltruncate <https://github.com/eentzel/htmltruncate.py> in 
a controller that return a SQLFORM.smartgrid and it works perfect:
 
def noticias():
    
    db.noticias.cuerpo.represent = lambda field,row: 
XML(htmltruncate.truncate(field, 100))
    grid = SQLFORM.smartgrid(db.noticias, 
linked_tables=['adjuntos_noticia'])

    return dict(grid =grid)


But when I try to implement a in a controller in this way:

def index():
    db.publicaciones.descripcion.represent = lambda field, row: 
XML(htmltruncate.truncate(field, 10))
    tipo_3 = db(db.publicaciones.tipo == 3).select().last()

    return dict(tipo_3 = tipo_3)


It doesn't work


The module is inside the "modules" folder of the app and it's imported via:
import htmltruncate


any help is welcome!

Best!

-- 



Reply via email to