Changeset 439


Ignore:
Timestamp:
09/09/08 13:24:50 (5 years ago)
Author:
cbalan
Message:

tracpaste: - Avoiding object re-fetch on recent posts page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/forks/tracpasteplugin/tracpaste/model.py

    r17 r439  
    1616    cursor.execute('select id, title, author, mimetype, data, time from pastes order by ' 
    1717                   'id desc limit 0, %s', (n,)) 
     18     
    1819    result = [] 
    1920    for row in cursor: 
     
    2324            author =    row[2], 
    2425            mimetype =  row[3], 
    25             data =      row[4], 
    26             time =      datetime.fromtimestamp(row[5], utc) 
     26            data =      row[4].count("\n")>10 and "\n".join(row[4].splitlines()[:10]+["[ ... ]"]) or row[4], 
     27            time =      datetime.fromtimestamp(row[5], utc), 
     28            fetch =     False 
    2729            ) 
    2830        ) 
     
    3638 
    3739    def __init__(self, env, id=None, title=u'', author=u'', 
    38                  mimetype='text/plain', data=u'', time=None): 
     40                 mimetype='text/plain', data=u'', time=None, fetch=True): 
    3941        self.env = env 
    4042        self.id = id 
     
    4547        self.time = time 
    4648 
    47         if id is not None: 
     49        if id is not None and fetch: 
    4850            db = env.get_db_cnx() 
    4951            cursor = db.cursor() 
Note: See TracChangeset for help on using the changeset viewer.