Re: [Rest2web-develop] processing uservalues as a test condition in a template
Brought to you by:
mjfoord
From: Michael F. <fuz...@vo...> - 2008-03-22 18:20:36
|
Ben wrote: > Michael Foord wrote: > >> if localnavbar == 'yes' >> > > Hi, Michael, > > Thank you for your email and have a good Easter holiday! > I'm afraid I tried this syntax as well, and I get an error since the > localnavbar doesn't seem to be defined [1]. > > This is what I've put in 2 rest files header: > uservalues > localnavbar: yes > /uservalues > > (to let you know, about 30 other files don't have this value defined, > if it matters?) > > This code is being executed for a file that doesn't have the variable defined - i.e. stage.txt. Is this in your template? If so it will be executed for every file. You could get round this by putting something like the following *before* the code: try: localnavbar except NameError: localnavbar = 'no' Michael > and the error is: > > Processing indexfile. > Guessing encoding. We guessed: UTF-8 > Building stage.html > [err] Traceback (most recent call last): > [err] File "/usr/bin/r2w", line 170, in <module> > [err] count = main(options, config) > [err] File "/usr/bin/r2w", line 103, in main > [err] return processor.walk() > [err] File > "/var/lib/python-support/python2.5/rest2web/restprocessor.py", line 468, > in walk > [err] errorcheck = self.execute_safely(self.buildsection) > [err] File > "/var/lib/python-support/python2.5/rest2web/restprocessor.py", line 218, > in execute_safely > [err] val = function(*args, **keywargs) > [err] File > "/var/lib/python-support/python2.5/rest2web/restprocessor.py", line > 1463, in buildsection > [err] thepage = render_well(temp_file, namespace, > final_encoding=final_encoding) > [err] File > "/var/lib/python-support/python2.5/rest2web/embedded_code.py", line 89, > in render_well > [err] template = render(template, namespace, > uservalues,final_encoding=final_encoding) > [err] File > "/var/lib/python-support/python2.5/rest2web/embedded_code.py", line 72, > in render > [err] value = fun(occ, namespace) > [err] File > "/var/lib/python-support/python2.5/rest2web/embedded_code.py", line 142, > in render_value_exec > [err] exec codeobj in namespace > [err] File "<string>", line 2, in <module> > [err] NameError: name 'localnavbar' is not defined > [err] > > (for your information, stage.txt does not have such a localnavbar value) > > -- Ben > > [1] yes, I've tried again and I fixed the little typo in your example > (ocalnavbar -> localnavbar). > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Rest2web-develop mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/rest2web-develop > |