Please forgive the newbieness of question.
I am generating interactive plots using matplotlib as suggested by
cookbook, which writes a file and then pulls it into a view. My question
is whether that file is protected from other users seeing it. A second
question is whether, as I hope, the plot file will go away after the
session is over.
The application takes in financial planning data, does some calculations
in a module and then writes both a message and a graph to the screen.
Current graph is a dummy.
@auth.requires_login()
def planA():
var={}
outputstr=''
graph=''
form=SQLFORM.factory(
Field('I', requires=IS_INT_IN_RANGE(0,10000000)),
Field('S', requires=IS_INT_IN_RANGE(0,10000000)),
Field('y', requires=IS_INT_IN_RANGE(0,10000000)),
Field('r', requires=IS_FLOAT_IN_RANGE(0.01,0.05)),
Field('tb', requires=IS_INT_IN_RANGE(0,100)),
Field('k', requires=IS_INT_IN_RANGE(0,100)),
Field('vo', requires=IS_INT_IN_RANGE(0,10000000)),
Field('Adjust',
requires=IS_IN_SET(['I','S','y','r','tb','k','vo'])))
if form.process(keepvalues=True).accepted:
response.flash='form accepted'
var['I']=int(request.vars['I'])
var['S']=int(request.vars['S'])
var['y']=int(request.vars['y'])
var['r']=float(request.vars['r'])
var['tb']=int(request.vars['tb'])
session.k=var['k']=int(request.vars['k'])
var['vo']=int(request.vars['vo'])
missing=request.vars['Adjust']
from jwplanner import findmissing
output=findmissing(var,missing) # adjusts designated input to find
best plan
outputstr="Revised %s = %s" % (missing, output)
graph=graph_planA()
elif form.errors:
response.flash='form has errors'
else:
response.flash = 'please fill in the form'
return dict(form=form,outputstr=outputstr,graph=graph)
@auth.requires_login()
# question do plots need to be stored in session to prevent conflict?
def graph_planA():
return HTML(BODY(
IMG(_src=URL('planA_plot'))))
@auth.requires_login()
def planA_plot():
response.headers['Content-Type']='image/png'
x=range(0,session.k,1)
y=[xi**1.3 for xi in x]ma
return myplot(ylab=T('Thousands of
Dollars'),xlab=T('Years'),data={'data':zip(x,y)})
--