On Sep 18, 2010, at 3:46 PM, Avik Basu wrote: > > I tried the following command in both my app (where URL) and the > welcome app (where URL does not fail): > > {{=gluon.html._gURL(request).__name__}} > > and the result for both apps was: > > _URL > > Does that provide any clues?
It verifies that both apps are really running with the right code. But for some reason, it seems to be messed up at the time that you run any controller in your app. That's a puzzle to me. I appreciate your patience... So, here's something we can try. In your first (alphabetically) model, create a dict: urldebug = dict() urldebug['model1name'] = URL.__name__ The idea will be to trace URL.__name__ as we progress through a request. So at the beginning of each model file: urldebug['model2name'] = URL.__name__ ...and one more at the end of your last model. Then one more in one of your failing controllers (that is, failing if you try to call URL with one argument; not actually failing, because we want to get to the view). Then pass urldebug to your view, and dump it there. {{=BEAUTIFY(urldebug)}} will do the trick. Hopefully we'll see the name change from _URL to URL at some point in the sequence, and then we can go lion hunting. > > On Sep 18, 5:03 pm, Jonathan Lundell <jlund...@pobox.com> wrote: >> Massimo, any ideas? >> >> On Sep 18, 2010, at 1:24 PM, Avik Basu wrote: >> >> >> >> >> >> >> >>> I put this: >>> {{=URL.__name__}} >> >>> in the view of my index page and it showed >>> URL >> >>> (not _URL as you said) >> >>> Also, I don't know if its helpful to mention that the latest format >>> for the URL function is not working anywhere in my app, not just in >>> appadmin. So, if I put: >> >>> {{=URL('index')}} >> >>> in my index page, I get the same syntax error that I had in appadmin. >> >> That's good to know. >> >> You could try this (you'll need to import gluon.html): >> >> {{=gluon.html._gURL(request).__name__}} >> >> That's what the global URL should be. >> >> I think you were saying that this works OK in the other apps, right? You >> could stick similar logic into welcome, for comparison purposes, good vs >> bad. You might have to delete the welcome/compiled directory. >> >> By way of background, the URL logic was updated not all that long ago. Have >> a look at html._gURL, and then compileapp.build_environment() to see how >> it's being used. URL is being replaced by the closure (I think it's a >> closure) _gURL(request), so the value of request gets bound to the URL call, >> without having to supply it all the time. >> >> Also, a single argument to the original URL is treated as the application, >> whereas the closure treats it as the function. We see the former in the >> syntax error print below, more evidence that we're not invoking the closure. >> >> >> >> >> >>> On Sep 18, 4:10 pm, Jonathan Lundell <jlund...@pobox.com> wrote: >>>> On Sep 18, 2010, at 12:52 PM, Avik Basu wrote: >> >>>>> Line 219 of gluon/compileapp.py is as you described it. I also deleted >>>>> the whole gluon directory and downloaded the latest source of web2py >>>>> before restarting the server. Also, as far as I can tell, I am not >>>>> doing anything tricky with Globals or the URL symbol in my models. >> >>>>> I now get the following syntax error: >> >>>>> SyntaxError: URL: a=index c=None f=None r=None u=URL >> >>>> Thanks. >> >>>> I realized after I sent that last request that the __name__ of URL might >>>> not be significant at this point, because we're inside the URL() function. >> >>>> This might be worth a try. In appadmin.py, near the beginning (after the >>>> imports, but before response.menu is set): >> >>>> logger = logging.getLogger('web2py') >>>> logger.warning('appadmin url.name=%s' % URL.__name__) >> >>>> What you *should* see is _URL. That's what I see if I stick it in my own >>>> appadmin. >> >>>>> On Sep 18, 3:33 pm, Jonathan Lundell <jlund...@pobox.com> wrote: >>>>>> On Sep 18, 2010, at 11:52 AM, Avik Basu wrote: >> >>>>>>> After restarting the server, I get the following error: >> >>>>>>> SyntaxError: URL: a=index c=None f=None r=None >> >>>>>> I was afraid of that, and I can't explain it. >> >>>>>> Please check that line 219 of gluon/compileapp.py is: >> >>>>>> environment['URL'] = html._gURL(request) >> >>>>>> And you might want to quit your server, delete all the .pyc files in >>>>>> gluon, and restart. >> >>>>>> Do you do anything tricky with globals() or the URL symbol in your >>>>>> models? >> >>>>>> And let's try one more printing attempt: >> >>>>>> if not (application and controller and function): >>>>>> if r: >>>>>> msg = 'URL: a=%s c=%s f=%s r.a=%s r.c=%s r.f=%s' % >>>>>> (application,controller,function,r.application,r.controller,r.function) >>>>>> else: >>>>>> msg = 'URL: a=%s c=%s f=%s r=%s u=%s' % >>>>>> (application,controller,function,r,URL.__name__) >>>>>> raise SyntaxError, msg >> >>>>>>> On Sep 18, 2:46 pm, Jonathan Lundell <jlund...@pobox.com> wrote: >>>>>>>> On Sep 18, 2010, at 11:40 AM, Avik Basu wrote: >> >>>>>>>>> When I replace the code in gluon/html.py, I still keep getting the >>>>>>>>> same SyntaxError ('not enough information to build the url') which >>>>>>>>> seems strange since that is not even in the code anymore. >> >>>>>>>>> I am sort of new to debugging the gluon code so I maybe making some >>>>>>>>> simple mistake. I did delete the html.pyc file. Do I need to restart >>>>>>>>> the server? >> >>>>>>>> I would assume so, given the message, and especially if you're not >>>>>>>> seeing html.pyc getting recreated. >> >>>>>>>>> On Sep 18, 2:31 pm, Jonathan Lundell <jlund...@pobox.com> wrote: >>>>>>>>>> On Sep 18, 2010, at 9:46 AM, Avik Basu wrote: >> >>>>>>>>>>> Sure, I'm happy to help debug. Send me the print statements when >>>>>>>>>>> you >>>>>>>>>>> get a chance. >> >>>>>>>>>> FWIW, I just did the same thing (move the current appadmin into my >>>>>>>>>> own app) and it seems to work OK; at least I can access >>>>>>>>>> appadmin/index OK.