Error in app: cannot unpack non-iterable NoneType object

956 views
Skip to first unread message

Константин Комков

unread,
Jun 20, 2019, 5:21:28 AM6/20/19
to web2py-users
I have that string in controller:
res,flag=send_application(msg,entrant_XML)
and send_application function:
def send_application(msg,entrant_XML):
 
#my code
 
return
('My message',False)
I get error:

Ticket ID

46.73.180.207.2019-06-20.10-47-49.e820b49a-8731-495f-9156-0d75ad265046

<class 'TypeError'> cannot unpack non-iterable NoneType object

Версия

web2py™Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
PythonPython 3.7.3: C:\Python\python.exe (prefix: C:\Python)

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Traceback (most recent call last):
File ".\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:\inetpub\wwwroot\applications\application\controllers/bak.py", line 2101, in <module>
File ".\gluon\globals.py", line 421, in <lambda>
self._caller = lambda f: f()
File "C:\inetpub\wwwroot\applications\application\controllers/bak.py", line 1625, in send_app
res,flag=send_application(msg,entrant_XML)
TypeError: cannot unpack non-iterable NoneType object

Error snapshot help

TypeError(cannot unpack non-iterable NoneType object)

inspect attributes

Frames

  • File C:\inetpub\wwwroot\gluon\restricted.py in restricted at line 219 код аргументы переменные

  • File C:\inetpub\wwwroot\applications\application\controllers\bak.py in <module> at line 2101 код аргументы переменные

  • File C:\inetpub\wwwroot\gluon\globals.py in <lambda> at line 421 код аргументы переменные

  • File C:\inetpub\wwwroot\applications\application\controllers\bak.py in send_app at line 1625 код аргументы переменные

    Function argument list

    ()

    Code listing
    1620.
    1621.
    1622.
    1623.
    1624.
    1625.
    1626.
    1627.
    1628.
    1629.
            )
    )
    if form.process(formname='form',onvalidation=check_agreement).accepted:
    msg=create_application(rectorRank,rectorName,vuzName)
    entrant_XML=create_XML_entrant(form.vars.abit_pass)
    res,flag=send_application(msg,entrant_XML)
    if flag:
    heading = ''
    statement = ''
    clear_abit_app()
    Variables
    resundefined
    flagundefined
    global send_application<function send_application>
    msg'<div align="right">My text</html>'
    entrant_XML'<?xml version="1.0" ?><entrant>\n <personaldat.../reg>\n </exam>\n </marks>\n </entrant>'

Константин Комков

unread,
Jun 20, 2019, 1:30:30 PM6/20/19
to web2py-users
I need add more information. Can error may be caused if my function don't have one condition:
def send_application(msg,entrant_XML):
    #Letter for operator
    try:
        oper = mail.send('oper...@domen.ru','Theme','Letter text...',attachments = files)
    except Exception:
        oper = False

    #Letter for entrant
    try:
        abit = mail.send(session.abit_email,'Theme','Letter text...')
    except Exception:
        abit = False

    if ((oper==True) & (abit==True)):
        return ('My message',True)
    elif ((oper==True) & (abit==False)):
        return ('My message',False)
    elif ((oper==False) & (abit==True)):
        return ('My message',False)
Here I don't have that:
    else ((False) & (False)):
        
return ('My message',False)
Now I get return ('My message',True) in 25 percent of the time. How can I improve that result? Maybe I need take several attemts, but without sending two the same letter on one email. We have own mail server.


Val K

unread,
Jun 20, 2019, 3:19:34 PM6/20/19
to web2py-users
1. & - is bitwise operator (just in case)
2. why not just  return ('My message', oper and abit)

Константин Комков

unread,
Jun 22, 2019, 3:04:41 AM6/22/19
to web...@googlegroups.com
Val K, I know that & is betwice operator) I can not return ('My message', oper and abit) becouse string 'My message' is different like:
if ((oper==True) & (abit==True)):
       return ('My message 1',True)
   elif ((oper==True) & (abit==False)):
       return ('My message 2',False)
   elif ((oper==False) & (abit==True)):
       return ('My message 3',False)
I want to know what I need to do for function mail return me true and if it return me false i repeat call that function (maybe 5 times like call to databese in web2py) for improve that:
Reply all
Reply to author
Forward
0 new messages