What I do in such cases is-- In the controller C.py, def myController1(): return dict()
for returning a dict, I write a script def getDict(): do the processing... D={key:value pairs go here} return response.json(D) In myController.html View file, ... access D by using {{=URL('app','C','getDict')}} Then parse D for whatever the purpose. I think this detaches the server side function 'getDict' from the main function 'myController1'. ---Vineet On Sep 13, 7:36 am, Hugh Barker <hbar...@gmail.com> wrote: > Yeah, copying the default generic.html to getsensors.html (and ditto > for *.json) worked. > > I'll try the debugging steps you suggested, see what I come up with. > > On Sep 13, 12:08 pm, Jonathan Lundell <jlund...@pobox.com> wrote: > > > > > On Sep 12, 2011, at 6:45 PM, Hugh Barker wrote: > > > > This is my db.py: > > > > from gluon.tools import Service > > > > db = DAL('postgres://postgres:@server/geospatial') > > > response.generic_patterns = ['*'] > > > service = Service() > > > Nothing jumps out at me. As a sanity check, you might try copying > > views/generic.html to views/default/getsensors.html and verify that it > > works as expected that way. If it doesn't work, at least it'd tell us that > > things were seriously strange (and if it does work you'd have a workaround). > > > If you feel like troubleshooting, try this. > > > In gluon/compileapp.py, find run_view_in. A local string badv is defined > > early on, which is the path you see below in the error message. Leave that > > definition along, but search forward for the two double uses of badv, in a > > pair of raise statements. I'm assuming that you haven't compiled your app? > > No appname/compiled/ directory? In that case we want the second raise. > > > Just before the raise, insert: badv = filename > > > We *should* see a full path ending views/generic.html. > > > > On Sep 13, 11:13 am, Jonathan Lundell <jlund...@pobox.com> wrote: > > >> On Sep 12, 2011, at 6:10 PM, Bruno Rocha wrote: > > > >>> do you have response.generic_patterns = ['*'] in your models? > > > >> The stock line (for security) is > > > >> response.generic_patterns = ['*'] if request.is_local else [] > > > >>> On Mon, Sep 12, 2011 at 9:50 PM, HughBarker <hbar...@gmail.com> wrote: > > >>> Hi all, > > >>> So I've got a controller that builds a dict of strings and returns > > >>> them - although I'm building the dict dynamically, essentially what > > >>> I'm doing is this: > > > >>> def getsensors(): > > >>> d = {'airTemp' : 'Air Temperature', 'PAR' : 'PAR', > > >>> 'IMOSPortRadiometer' : 'IMOS Port Radiometer'} > > >>> return d > > > >>> When I call the URL, ie ../default/getsensors, I get 'invalid view > > >>> (default/getsensors.html)'. > > > >>> My understanding was that if a dict is returned from a controller and > > >>> you call the appropriate URL, the dict will get processed and > > >>> displayed on screen (ultimately what I'm trying to do is call > > >>> getsensors.json and process the returned JSON, kind of like Example 3 > > >>> athttp://web2py.com/examples/default/examples). > > > >>> I've played around with this a fair bit now, and I can't understand > > >>> why it isn't working. I'm sure it's some elementary mistake on my > > >>> part, but any help would be appreciated. > > > >>> -Hugh > > > >>> -- > > > >>> -- > > >>> Bruno Rocha > > >>> [ About me:http://zerp.ly/rochacbruno] > > >>> [ Aprenda a programar:http://CursoDePython.com.br] > > >>> [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br] > > >>> [ Consultoria em desenvolvimento web:http://www.blouweb.com]- Hide > > >>> quoted text - > > - Show quoted text -