global name DIV not defined

65 views
Skip to first unread message

Lars

unread,
Mar 13, 2017, 11:56:58 AM3/13/17
to web...@googlegroups.com
Hi,

I have this small code in the dashboard module:

from gluon.html import DIV
def get_dashboard():
   
return DIV(
        DIV
('Lorat ipsum etc', _class='dashboard alert'),
        _class
='center-box').xml()

and this one in default.py :

def index():
   
from modelling.dashboard import get_dashboard
    dashboard
= get_dashboard()
   
return dict(message=message, dashboard=dashboard)



And I noticed that if I refresh the page to quickly sometimes I have the error :
global name DIV is not defined

or some other, the css is not defined ? Both never happens when the DIV is defined in default.py.

Could anybody figure why ? And how to avoid this ?

Thank you,

Richard Vézina

unread,
Mar 13, 2017, 3:13:44 PM3/13/17
to web2py-users
I think you want to import from sqlhtml :


Try like this :
from gluon.sqlhtml import *

Richard

On Mon, Mar 13, 2017 at 11:56 AM, Lars <laer...@gmx.fr> wrote:
Hi,

I have this small code in the dashboard module:

from gluon.html import DIV
def get_dashboard():
   
return DIV(
        DIV
('Lorat ipsum etc', _class='dashboard alert'),
        _class
='center-box').xml()

and this one in default.py :

def index():
   
from modelling.dashboard import get_dashboard
    dashboard
= get_dashboard()
   
return dict(message=message, dashboard=dashboard



And I noticed that if I refresh the page to quickly sometimes I have the error :
global name DIV is not defined

or some other, the css is not defined ?

Could anybody figure why ? And how to avoid this ?

Thank you,

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony

unread,
Mar 13, 2017, 6:20:55 PM3/13/17
to web2py-users
No, DIV is in gluon.html.

Richard Vézina

unread,
Mar 13, 2017, 8:07:13 PM3/13/17
to web2py-users
So the problem is from .xml() than??

Richard

On Mon, Mar 13, 2017 at 6:20 PM, Anthony <abas...@gmail.com> wrote:
No, DIV is in gluon.html.

Lars

unread,
Mar 14, 2017, 3:23:57 PM3/14/17
to web2py-users
Actually it comes from T, the issue remains even with no xml() or XML involved.

Sorry but I reduced the function to the wrong line : I had a T = current.T at the beginning of get_dashboard() which
deletion didn't suppress the issue.

It seems that an involuntary (my bad) spelling of the returned string (message='Lorat ..') created multiple versions of the message in LANG.py which then create a bad dictionary that contains different possible translations for the same item in uwsgi cache.

Rewrite (sanitize) lang.py by hand and restart uwsgi does the trick.

Thank you


 

On Tuesday, March 14, 2017 at 1:07:13 AM UTC+1, Richard wrote:
So the problem is from .xml() than??

Richard
On Mon, Mar 13, 2017 at 6:20 PM, Anthony <abas...@gmail.com> wrote:
No, DIV is in gluon.html.

--
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+un...@googlegroups.com.

Richard Vézina

unread,
Mar 14, 2017, 4:40:08 PM3/14/17
to web2py-users
You can pass T() to module or use current.T(), I think the later is the proper way to do now as current wasn't existing before we had to pass request, T(), etc...


"Other objects and modules are defined in the libraries, but they are not automatically imported since they are not used as often.

The core API entities in the web2py execution environment are requestresponsesessioncacheURLHTTPredirect and Tand are discussed below."


Then a little further :



To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.

Richard Vézina

unread,
Mar 14, 2017, 4:40:36 PM3/14/17
to web2py-users

Lars

unread,
Mar 15, 2017, 4:40:22 AM3/15/17
to web2py-users
I don't now about before (I don't have much experience) but the book specifies not to pass current at module level, only in functions.
Thanks for the hint anyway. :)
Reply all
Reply to author
Forward
0 new messages