As part of a router function I have the following code:

id=request.args(0)
account=db(db.NodeAccount.nodeID==id).select(db.NodeAccount.ALL).first()
if account:
    if account.statusID!=1: # in that case the account is blocked or under 
maintenance
        redirect(URL('card',args=id))
    elif account.accountID==ADVANCEDACCOUNTID:
        if not session[id]:
            session[id]=Storage(id=id)
            session[id].accountid=ADVANCEDACCOUNTID
        redirect(URL('site','index',args=id))
    elif account.accountID==ADVANCEDCONNECTORACCOUNTID:
        if not session[id]:
            session[id]=Storage(id=id)
            session[id].accountid=ADVANCEDCONNECTORACCOUNTID
        redirect(URL('connector','index',args=id))

In a controller I start the index function with the following code:

if not len(request.args):
        redirect(URL('addressbook','router'))
    elif not session[request.args(0)]:
        redirect(URL('addressbook','router',request.args(0)))
    elif not session[request.args(0)].accountid==ADVANCEDACCOUNTID:
        redirect(URL('addressbook','router',request.args(0)))
    else:
        ....

When I have an object session[283] and visit the url: 
http://127.0.0.1:8000/bootstrap/site/index/283 and then change 283 to 2053: 
http://127.0.0.1:8000/bootstrap/site/index/2053
(and session[2053] doesn't exist) instead of a redirection to 
http://127.0.0.1:8000/bootstrap/addressbook/router/2053 I get an invalid 
request: http://127.0.0.1:8000/addressbook/router/2053

When I add the application to the url:  
redirect(URL('bootstrap','addressbook','router',request.args(0))),  I get:

Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py", line 
205, in restricted
    exec ccode in environment
  File 
"/Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py"
 <http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py>, line 
192, in <module>
  File "/Library/Python/2.5/site-packages/web2py/gluon/globals.py", line 173, 
in <lambda>
    self._caller = lambda f: f()
  File 
"/Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/site.py"
 <http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/site.py>, line 
19, in index
    redirect(URL('bootstrap','addressbook','router',request.args(0)))
  File "/Library/Python/2.5/site-packages/web2py/gluon/html.py", line 246, in 
URL
    application = r.application
AttributeError: 'str' object has no attribute 'application'


Why doesn't this work?

Kind regards,

Annet.


-- 



Reply via email to