Thanks Massimo. Perfect. On Saturday, 25 October 2014 07:52:03 UTC+8, Massimo Di Pierro wrote: > > Normally modules are not reloaded because they are cached by python. > web2py can bypass this, depending on where the modules are located. If you > kwwp in your modules in the web2py app/modules folder then you can do in > your models/db.py > > DEBUG=True > from gluon.custom_import import track_changes; track_changes(DEBUG) > > This will reload your modules when they change/ > > > > On Friday, 24 October 2014 03:33:33 UTC-5, tahnoon pasha wrote: >> >> Hi, >> >> Working with a team building a reasonably complex webapp for an >> investment management system, and I'm trying to learn something of the >> system too. >> >> I have a module that updates data from a file (simulating an FTP drop). >> Once the module has been loaded the first time, it doesn't update for >> either changes in code or in the underlying data no matter how often I >> refresh the page. >> >> Is there a particular way to force web2py to reload any files each time a >> page is refreshed? Am I doing something completely wrong? >> >> Thanks >> >> The code is as follows: >> >> module: *dataxl.py* >> >> from gluon import * >> import csv >> import json >> import os >> from xlrd import open_workbook as lox >> >> >> >> >> def mydata(): >> filepath = os.join(current.request.folder, 'static', 'sample-data', \ >> '20-10-2014_sample-data-for-designer.xls') >> oldbook = lox(filepath) >> names = oldbook.sheet_names() >> workbook = {} >> for name in names: >> worksheet = [] >> oldsheet = ws.sheet_by_name(name) >> nrows = oldsheet.nrows >> ncols = oldsheet.ncols >> colnames = [ oldsheet.cell(0,i).value for i in range(ncols) ] >> rownames = [ oldsheet.cell(i,0).value for i in range(nrows) ] >> for nrow in xrange(1,nrows): >> worksheet.append({colnames[ncol]: oldsheet.cell(nrow,ncol).value >> \ >> for ncol in xrange(ncols)}) >> workbook[name] = worksheet >> return workbook >> >> controller: *performance.py* >> >> import dataxl >> >> >> wsheet = dataxl.mydata() >> >> attr = wsheet[ 'Performance_Attr' ] >> >> @auth.requires_login() >> def perf_multi_asset(): >> >> clientId = set(i[ 'client' ] for i in attr.values()) >> portId = [ 'All' ] >> portId.append(j for j in set(i[0] for i in attr.items() \ >> if i[ 1 ][ 'Attribution Level' ] == 0 \ >> or i[ 1 ][ 'Attribution Level' ] == 1)) >> >> perform = SQLFORM.factory( >> Field('client', 'string'),requires=IS_IN_SET(clientId)), >> Field('portfolio', 'string'),requires=IS_IN_SET(portId)), >> Field('start_date', 'date'), >> Field('end_date', 'date') >> ).process() >> >> if perform.vars.portfolio == 'All': >> data = {i[ 0 ]:i[ 1 ] for i in attr.items() if i[ 1 ][ 'client' ] >> == perform.vars.client} >> else: >> data = {i[ 0 ]:i[ 1 ] for i in attr.items() if i[ 1 ][ 'client' ] >> == perform.vars.client \ >> and i[ 0 ] == perform.vars.portfolio} >> >> return locals() >> >> and view: *performance/perf_multi_asset.html* >> >> {{left_sidebar_enabled,right_sidebar_enabled=False,('message' in globals >> ())}} >> {{extend 'layout.html'}} >> >> {{=STYLE(XML(".generic-widget,#no_table_start_date,#no_table_end_date >> {width:100px}"))}} >> >> <div class="row"> >> {{=perform.custom.begin}} >> >> <div class="span2"> >> Client Name: <br> >> {{=perform.custom.widget.client}} >> </div> >> >> <div class="span2"> >> Portfolio ID: <br> >> {{=perform.custom.widget.portfolio}} >> </div> >> >> <div class="span2"> >> Start Date: <br> >> {{=perform.custom.widget.start_date}} >> </div> >> >> <div class="span2"> >> End Date: <br> >> {{=perform.custom.widget.end_date}} >> </div> >> >> <div class="span2"> >> <br> >> {{=perform.custom.submit}} >> </div> >> >> {{=perform.custom.end}} >> >> </div> >> >> {{=BEAUTIFY(XML(data))}} >> >>
-- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.