See http://web2py.com/book/default/chapter/04#Third-Party-Modules. Note, if your function needs to refer to some of the web2py global objects (as yours does), then you will need to explicitly pass them to the function as arguments (external modules cannot "see" web2py globals).
On Saturday, April 9, 2011 3:08:10 AM UTC-4, 黄祥 wrote: > hi, > > i read in > http://web2py.com/book/default/chapter/11#Efficiency-and-Scalability > it said : > define functions in modules, import them and use those functions as > needed. > does anyone know how to define functions in modules and then import > it? > e.g. > > def manage(): > table = db.blog > form = crud.update(table, request.args(1), message = T("Succeed")) > table.id.represent = lambda id: A('Edit:', id, _href = URL(args = > (request.args(0), id))) > search, rows = crud.search(table) > return dict(form = form, search = search, rows = rows) > > thank you very much

