2011-10-03 58 views

回答

2

你可以做到這一點在許多方面:

第一:

db.table.field.represent = lambda r, v: IMG(_src=URL('default', 
                'download', 
                 args=v.field)) 

# where field is the field where your picture lives. 

二是使用的web2py虛擬領域:

class MyVirtual(object): 
    def photo(self): 
     return IMG(_src=URL('default', 'download', args=self.table.field)) 

db.table.virtualfields.append(MyVirtual()) 

table = SQLTABLE(db(db.table).select()) 

三是使用中extraColumns:

myextracolumns = [{'label': 'My Photo', 
        'content': lambda row, rc: IMG(_src=URL('default', 
                  'download', 
                  args=row.field))}] 

table = SQLTABLE(rows, extracolumns=myextracolumns)